package cc.telecomdigital.tdstock.activity.groups.index;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources.NotFoundException;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Animation.AnimationListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import cc.mango.common.FinalKey;
import cc.telecomdigital.tdstock.ColorRefreshTask;
import cc.telecomdigital.tdstock.CommonDefn;
import cc.telecomdigital.tdstock.CustomizeDialog;
import cc.telecomdigital.tdstock.DBHelper;
import cc.telecomdigital.tdstock.DefaultClickHandler;
import cc.telecomdigital.tdstock.ITDLApplication;
import cc.telecomdigital.tdstock.LightStreamerHandlerInterface;
import cc.telecomdigital.tdstock.R;
import cc.telecomdigital.tdstock.RefreshHandlerInterface;
import cc.telecomdigital.tdstock.StringUtils;
import cc.telecomdigital.tdstock.SystemInfo;
import cc.telecomdigital.tdstock.CommonDefn.DataMode;
import cc.telecomdigital.tdstock.CommonDefn.DoThingsReturn;
import cc.telecomdigital.tdstock.CommonDefn.ModeType;
import cc.telecomdigital.tdstock.Framework.UniqueItem.TDStockLog;
import cc.telecomdigital.tdstock.Services.LS_SubscriptionItem;
import cc.telecomdigital.tdstock.Services.LS_UserClient.CONNECTION_STATUS;
import cc.telecomdigital.tdstock.Services.LS_UserClient.ILS_UserClient_Response;
import cc.telecomdigital.tdstock.Tools.ActivityGroupController;
import cc.telecomdigital.tdstock.activity.ChangePortraitAndLandscapeActivity;
import cc.telecomdigital.tdstock.activity.chart.IndexChartActivity;
import cc.telecomdigital.tdstock.activity.groups.IndexGroup;
import cc.telecomdigital.tdstock.activity.groups.monitor.util.MonitorUtil;
import cc.telecomdigital.tdstock.activity.groups.monitor.util.SaveBookMarkAsyncTask;
import cc.telecomdigital.tdstock.model.IndexFuturesInfo;
import cc.telecomdigital.tdstock.model.IndexInfo;
import cc.telecomdigital.tdstock.model.WorldFuturesInfo;
import cc.telecomdigital.tdstock.model.WorldIndexDelayInfo;
import cc.telecomdigital.tdstock.model.WorldIndexInfo;

import com.lightstreamer.ls_client.UpdateInfo;

public class IndexActivity extends ChangePortraitAndLandscapeActivity implements
	RefreshHandlerInterface, ILS_UserClient_Response
{
	// changed by zhengan

	List<String>	noChartList	= new ArrayList<String>();

	// private String currentItemCode ;

	@Override
	public Handler getHandler()
	{
		if (((ITDLApplication) getApplicationContext()).isExitApp())
		{
			return null;
		}
		return _messageHandler;
	}

	@Override
	public void updateBackground(Object handlerId, int color)
	{
		if (!(handlerId instanceof DoThingsReturn))
		{
			return; // invalid parameter
		}
		else
		{
			TextView current = (TextView) (((DoThingsReturn) handlerId).data);
			if (current.getVisibility() != View.VISIBLE)
			{
				return; // no need to update for the view
			}
			if (color <= 0)
			{
				current.setBackgroundDrawable(null);
				current.setText(((DoThingsReturn) handlerId).cmd.toString());
			}
			else
			{
				current.setBackgroundColor(color);
			}
			// modified by haibo, 2011-06-20, no need to do so and it cause the
			// anr. current.postInvalidate();
		}

	}

	private boolean								_isSubscribed								= false;
	public String									TAG										= IndexActivity.class
																								.getSimpleName();
	private NumberFormat							_formater;
	private static final String						INDEX_NAME_HSI								= "HSI";
	private static final String						INDEX_NAME_HSCEI							= "HSCEI";

	/*-----"上証SSEI"-----by ouyangzhihui 2011-08-25---------*/
	private static final String[]						WORLD_INDEX_ITEMS_DELAY_AND_REALTIME			= {
			"SSE1", "SS300", "SSE1", "SSEA", "SSEB"											};
	/*-----"上証SSEI"-----by ouyangzhihui 2011-08-25---------*/
	private static final String[]						WORLD_INDEX_ITEMS							= {
			/* "SSE1", */"N225", "FTSE", "GDAX", "DJI", /*
														 * "SS300", "SSE1", "SSEA",
														 * "SSEB",
														 */"N225",
			"KOSPI", "STI", "TWII", "AORD", "NZTOP",
			/* "BOMBAY", */"THAI", "JKSE", "KLSE", "PHSI", "DJI", "NDX",
			"SP500",/* 隐藏印度SEN index=10 */
			"FTSE", "CAC40", "GDAX"															};

	private static final String[]						INDEX_FUTURES_ITEMS							= {
			"HSI:1", "HSI:2", "HHI:1", "HHI:2"												};
	private static final String[]						WORLD_FUTURES_ITEMS							= {
			"SSI:1", "SSI:2", "DJI:1"														};

	private static int[]							INDEX_FUTURES_LABEL_IDS;

	private static int[]							INDEX_FUTURES_LABEL_IDS_2;

	private static final String[]						INDEX_TELETEXT_ALL_ITEMS						= {
			INDEX_NAME_HSI, INDEX_NAME_HSCEI, "HSCCI", "GEM", "HSI-FIN",
			"HSI-UTL", "HSI-PRO", "HSI-CnI"													};

	private static final int[]						INDEX_CATEGORY								= {
			R.id.index_rc, R.id.index_ep, R.id.index_finance,
			R.id.index_public, R.id.index_estate, R.id.index_ic									};

	private static final int[]						INDEX_CATEGORY_LABEL						= {
			R.string.index_rc_label, R.string.index_ep_label,
			R.string.index_finance_label, R.string.index_public_label,
			R.string.index_estate_label, R.string.index_ic_label									};

	private TextView[][]							_index_category							= new TextView[6][7];

	private static final int[]						TAB_BTN_IDS								= {
			R.id.index_preset_btn, R.id.index_hk_btn, R.id.index_szsh_btn,
			R.id.index_asia_btn, R.id.index_occident_btn										};
	private Button[]								_tabBtns									= new Button[5];

	private static final String[]						WORLD_INDEX_DELAY_ITEMS						= {
			"SZEA", "SZEB"																};

	private static final int[]						WORLD_INDEX_DELAY_IDS						= {
			R.id.index_szsza, R.id.index_szszb												};

	private static final int[]						WORLD_INDEX_DELAY_LABEL						= {
			R.string.index_sza_label, R.string.index_szb_label									};

	private TextView[][]							_worldIndex_delay							= new TextView[2][7];

	// hold itemcode & adapter, index
	private static HashMap<String, Integer>				ITEM_TO_TABINDEX							= new HashMap<String, Integer>();
	static
	{
		// -----------------0--------------------
		ITEM_TO_TABINDEX.put(INDEX_NAME_HSI + IndexInfo.ADAPTER, 0); // 0 恒生指数

		ITEM_TO_TABINDEX.put(INDEX_FUTURES_ITEMS[0]
				+ IndexFuturesInfo.ADAPTER, 0); // 1恒生指数11月期货
		ITEM_TO_TABINDEX.put(INDEX_FUTURES_ITEMS[1]
				+ IndexFuturesInfo.ADAPTER, 0); // 2恒生指数12月期货

		ITEM_TO_TABINDEX.put(INDEX_NAME_HSCEI + IndexInfo.ADAPTER, 0); // 3国企指数

		ITEM_TO_TABINDEX.put(INDEX_FUTURES_ITEMS[2]
				+ IndexFuturesInfo.ADAPTER, 0); // 4国企指数11月期货
		ITEM_TO_TABINDEX.put(INDEX_FUTURES_ITEMS[3]
				+ IndexFuturesInfo.ADAPTER, 0); // 5国企指数12月期货

		ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS_DELAY_AND_REALTIME[1], 0); // 6
																// 上证指数
		ITEM_TO_TABINDEX
				.put(WORLD_INDEX_ITEMS[0] + WorldIndexInfo.ADAPTER, 0); // 7
																// 日经指数

		ITEM_TO_TABINDEX.put(WORLD_FUTURES_ITEMS[0]
				+ WorldFuturesInfo.ADAPTER, 0); // 8日经12月
		ITEM_TO_TABINDEX.put(WORLD_FUTURES_ITEMS[1]
				+ WorldFuturesInfo.ADAPTER, 0); // 9日经3月
		ITEM_TO_TABINDEX
				.put(WORLD_INDEX_ITEMS[1] + WorldIndexInfo.ADAPTER, 0); // 10伦敦富时
		ITEM_TO_TABINDEX
				.put(WORLD_INDEX_ITEMS[2] + WorldIndexInfo.ADAPTER, 0); // 11德国DAX
		ITEM_TO_TABINDEX
				.put(WORLD_INDEX_ITEMS[3] + WorldIndexInfo.ADAPTER, 0); // 12道琼斯
		ITEM_TO_TABINDEX.put(WORLD_FUTURES_ITEMS[2]
				+ WorldFuturesInfo.ADAPTER, 0); // 13道指12月
		// -----------------0--------------------

		// -----------------1--------------------
		// ---------------分类-----------------
		ITEM_TO_TABINDEX.put(INDEX_TELETEXT_ALL_ITEMS[2], 1);
		ITEM_TO_TABINDEX.put(INDEX_TELETEXT_ALL_ITEMS[3], 1);
		ITEM_TO_TABINDEX.put(INDEX_TELETEXT_ALL_ITEMS[4], 1);
		ITEM_TO_TABINDEX.put(INDEX_TELETEXT_ALL_ITEMS[5], 1);
		ITEM_TO_TABINDEX.put(INDEX_TELETEXT_ALL_ITEMS[6], 1);
		ITEM_TO_TABINDEX.put(INDEX_TELETEXT_ALL_ITEMS[7], 1);
		// ---------------分类-----------------

		// -----------------1--------------------

		// -----------------2--------------------

		ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS_DELAY_AND_REALTIME[1], 2);
		ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS_DELAY_AND_REALTIME[2], 2);
		ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS_DELAY_AND_REALTIME[3], 2);
		ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS_DELAY_AND_REALTIME[4], 2);

		ITEM_TO_TABINDEX.put(WORLD_INDEX_DELAY_ITEMS[0]
				+ WorldIndexDelayInfo.ADAPTER, 2);
		ITEM_TO_TABINDEX.put(WORLD_INDEX_DELAY_ITEMS[1]
				+ WorldIndexDelayInfo.ADAPTER, 2);

		// -----------------2--------------------

		// -----------------3--------------------

		ITEM_TO_TABINDEX
				.put(WORLD_INDEX_ITEMS[4] + WorldIndexInfo.ADAPTER, 3);
		ITEM_TO_TABINDEX
				.put(WORLD_INDEX_ITEMS[5] + WorldIndexInfo.ADAPTER, 3);
		ITEM_TO_TABINDEX
				.put(WORLD_INDEX_ITEMS[6] + WorldIndexInfo.ADAPTER, 3);
		ITEM_TO_TABINDEX
				.put(WORLD_INDEX_ITEMS[7] + WorldIndexInfo.ADAPTER, 3);
		ITEM_TO_TABINDEX
				.put(WORLD_INDEX_ITEMS[8] + WorldIndexInfo.ADAPTER, 3);
		ITEM_TO_TABINDEX
				.put(WORLD_INDEX_ITEMS[9] + WorldIndexInfo.ADAPTER, 3);
		ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS[10] + WorldIndexInfo.ADAPTER,
				3);
		ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS[11] + WorldIndexInfo.ADAPTER,
				3);
		ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS[12] + WorldIndexInfo.ADAPTER,
				3);
		ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS[13] + WorldIndexInfo.ADAPTER,
				3);
		ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS[14] + WorldIndexInfo.ADAPTER,
				3);
		// -----------------3--------------------

		// -----------------4--------------------
		ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS[16] + WorldIndexInfo.ADAPTER,
				4);
		ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS[17] + WorldIndexInfo.ADAPTER,
				4);
		ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS[18] + WorldIndexInfo.ADAPTER,
				4);
		ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS[19] + WorldIndexInfo.ADAPTER,
				4);
		// ITEM_TO_TABINDEX.put(WORLD_INDEX_ITEMS[20] + WorldIndexInfo.ADAPTER,
		// 4);/*隐藏印度SEN index=10*/
		// -----------------4--------------------

	}
	/*-----"上証SSEI"-----by ouyangzhihui 2011-08-25---------*/
	private static final int[]						WORLD_INDEX_DELAYREALTIME_IDS					= {
			R.id.index_preset_sse, // 上証指數
			R.id.index_szsh300, // 滬深300
			R.id.index_shsse, // 上証指數
			R.id.index_shssa, // 上海SSA
			R.id.index_shssb																// 上海SSB
																						};
	/*-----"上証SSEI"-----by ouyangzhihui 2011-08-25---------*/
	private static final int[]						WORLD_INDEX_IDS							= {
																						// R.id.index_preset_sse, // 上証指數
			R.id.index_preset_jp, // 日經指數(延遲)
			R.id.index_preset_london,// 倫敦富時(延遲)
			R.id.index_preset_dax, // 德國DAX(延遲)
			R.id.index_preset_dj, // 道瓊斯(延遲)
			// R.id.index_szsh300, // 滬深300
			// R.id.index_shsse, // 上証指數
			// R.id.index_shssa, // 上海SSA
			// R.id.index_shssb, // 上海SSB
			R.id.index_jp, // 日經指數
			R.id.index_kospi, // 南韓KOSPI
			R.id.index_sti, // 新加坡STI
			R.id.index_tai, // 加權TAI
			R.id.index_aord, // 澳洲AORD
			R.id.index_nzx, // 新西蘭NZX
			/* R.id.index_sen, */// 印度SEN /*隐藏印度SEN index=10*/
			R.id.index_set, // 曼谷SET
			R.id.index_jkt, // 椰加達JKT
			R.id.index_kls, // 吉隆坡KLS
			R.id.index_psi, // 馬尼拉PSI
			R.id.index_dj, // 道瓊斯
			R.id.index_nasd, // 納指NASD
			R.id.index_sp, // 標普S&P
			R.id.index_ftse, // 倫敦FTSE
			R.id.index_cac, // 法國CAC
			R.id.index_dax																// 德國DAX
																						};
	/*-----"上証SSEI"-----by ouyangzhihui 2011-08-25---------*/
	private static final int[]						WORLD_INDEX_DELAYREALTIME_LABEL_IDS			= {
			R.string.index_sse1_label, R.string.index_ss300_label,
			R.string.index_sse1_label, R.string.index_ssea_label,
			R.string.index_sseb_label														};
	/*-----"上証SSEI"-----by ouyangzhihui 2011-08-25---------*/
	private static final int[]						WORLD_INDEX_LABEL_IDS						= {
			/* R.string.index_sse1_label, */R.string.index_n225_label,
			R.string.index_ftse_label, R.string.index_gdax_label,
			R.string.index_dji_label, /*
									 * R.string.index_ss300_label,
									 * R.string.index_sse1_label,
									 * R.string.index_ssea_label,
									 * R.string.index_sseb_label,
									 */R.string.index_n225_label_2,
			R.string.index_kospi_label, R.string.index_sti_label,
			R.string.index_twii_label, R.string.index_aord_label,
			R.string.index_nztop_label, /* R.string.index_bombay_label, *//*
																		 * 隐藏印度SEN
																		 * index
																		 * =10
																		 */
			R.string.index_thai_label, R.string.index_jkse_label,
			R.string.index_klse_label, R.string.index_phsi_label,
			R.string.index_dji_label_2, R.string.index_ndx_label,
			R.string.index_sp500_label, R.string.index_ftse_label_2,
			R.string.index_cac40_label, R.string.index_gdax_label_2,								};

	private static final String[]						TAGS										= {
			"index_value", "index_net", "index_net_percentage",
			"index_high", "index_low", "index_open", "index_prev"									};
	private static final String						REPLACEMENT_TAG							= "replacement_tag";
	private static final String						NAME_TAG									= "index_name";
	private static final String						NAME_ADDTO_MONITOR_TAG						= "addto_monitor_tag";
	private final static String						TAG_CHART									= "fx_chart";

	// private final static int[] IDS_TAB_PANEL = {R.id.index_preset_tab,
	// R.id.index_szsh_tab,R.id.index_asia_tab, R.id.index_occident_tab,
	// R.id.index_category_tab};
	private final static int[]						IDS_TAB_PANEL								= {
			R.id.index_preset_tab, R.id.index_hk_tab, R.id.index_szsh_tab,
			R.id.index_asia_tab, R.id.index_occident_tab										};

	private TextView[][]							_index_hsi_views							= new TextView[2][7];
	private TextView[][]							_index_hscei_views							= new TextView[2][7];
	private TextView[][][]							_index_futures_views						= new TextView[2][7][7];		// the
																													// first
																													// four
																													// is
																													// futures,
																													// the
																													// left
																													// is
																													// world
																													// futures;
	/*-----"上証SSEI"-----by ouyangzhihui 2011-08-25---------*/
	private TextView[][]							_world_index_delay_realtime_views				= new TextView[5][7];
	/*-----"上証SSEI"-----by ouyangzhihui 2011-08-25---------*/
	private TextView[][]							_world_index_views							= new TextView[21 - 1][7];		/*
																															 * 隐藏印度SEN
																															 * index=10
																															 */
	// private ImageView _toolbutton_options;
	private Button									_toolbutton_options;

	private TextView								_top_bar_title;

	public final static int							BUFFERED_READER_SIZE						= 24 * 1024;					// 24K;

	private ImageView								_chartImg									= null;
	// private static StreamerTimeoutHandler _streamerTimeoutHandler;
	private Context								_context;

	private LightStreamerHandlerOnIndex				_lightStreamerHandlerOnIndex					= null;
	private LightStreamerHandlerOnWorldIndexDelayRealtime	_lightStreamerHandlerOnWorldIndexDelayRealtime	= null;
	private LightStreamerHandlerOnWorldIndex			_lightStreamerHandlerOnWorldIndex				= null;
	private LightStreamerHandlerOnIndexFutures			_lightStreamerHandlerOnIndexFutures			= null;
	private LightStreamerHandlerOnWorldFutures			_lightStreamerHandlerOnWorldFutures			= null;
	private LightStreamerHandlerOnWorldIndexDelay		_lightStreamerHandlerOnWorldIndexDelay			= null;

	private static Integer							CHART_IMG_TAG_FOR_KEY						= R.id.index_preset_sse;
	private static Integer							CHART_IMG_TAG_FOR_CLICK						= R.id.index_dax;

	private final boolean							usingBlinkColumn							= true;
	private final int								blinkTime									= 300;
	private final int								INFO_CONTENT_UPDATE							= 1;

	private static String							IDENTIFIER_0								= IndexActivity.class
																								.getSimpleName()
																								+ "00";
	private static String							IDENTIFIER_1								= IndexActivity.class
																								.getSimpleName()
																								+ "01";
	private static String							IDENTIFIER_2								= IndexActivity.class
																								.getSimpleName()
																								+ "02";
	private static String							IDENTIFIER_3								= IndexActivity.class
																								.getSimpleName()
																								+ "03";
	private static String							IDENTIFIER_4								= IndexActivity.class
																								.getSimpleName()
																								+ "04";
	private static String							IDENTIFIER_5								= IndexActivity.class
																								.getSimpleName()
																								+ "05";

	private static HashMap<Integer, Integer>			TAB4And5Map								= new HashMap<Integer, Integer>();
	private static HashMap<Integer, Integer>			TAB1And3Map								= new HashMap<Integer, Integer>();
	private static HashMap<Integer, Integer>			TAB1And2Map								= new HashMap<Integer, Integer>();
	static
	{
		TAB1And2Map.put(R.id.index_phsi_current_month, 1);
		TAB1And2Map.put(R.id.index_phsi_next_month, 1);
		TAB1And2Map.put(R.id.index_hscei_current_month, 1);
		TAB1And2Map.put(R.id.index_hscei_next_month, 1);
	}
	static
	{

		TAB1And3Map.put(R.id.index_preset_sse, 1);

		TAB1And3Map.put(R.id.index_szsh300, 3);
		TAB1And3Map.put(R.id.index_shsse, 3);
		TAB1And3Map.put(R.id.index_shssa, 3);
		TAB1And3Map.put(R.id.index_shssb, 3);
	}
	static
	{

		TAB4And5Map.put(R.id.index_preset_jp, 1);
		TAB4And5Map.put(R.id.index_jp_later_month, 1);
		TAB4And5Map.put(R.id.index_jp_more_later_month, 1);
		TAB4And5Map.put(R.id.index_preset_london, 1);
		TAB4And5Map.put(R.id.index_preset_dax, 1);
		TAB4And5Map.put(R.id.index_preset_dj, 1);
		TAB4And5Map.put(R.id.index_dj_later_month, 1);

		TAB4And5Map.put(R.id.index_szsza, 3);
		TAB4And5Map.put(R.id.index_szszb, 3);

		TAB4And5Map.put(R.id.index_jp, 4);
		TAB4And5Map.put(R.id.index_jp_later_month, 4);
		TAB4And5Map.put(R.id.index_jp_more_later_month, 4);
		TAB4And5Map.put(R.id.index_kospi, 4);
		TAB4And5Map.put(R.id.index_sti, 4);
		TAB4And5Map.put(R.id.index_tai, 4);
		TAB4And5Map.put(R.id.index_aord, 4);
		TAB4And5Map.put(R.id.index_nzx, 4);
		// TAB4And5Map.put( R.id.index_sen, 4);/*隐藏印度SEN index=10*/
		TAB4And5Map.put(R.id.index_set, 4);
		TAB4And5Map.put(R.id.index_jkt, 4);
		TAB4And5Map.put(R.id.index_kls, 4);
		TAB4And5Map.put(R.id.index_psi, 4);

		TAB4And5Map.put(R.id.index_dj, 5);
		TAB4And5Map.put(R.id.index_dj_later_month, 5);
		TAB4And5Map.put(R.id.index_nasd, 5);
		TAB4And5Map.put(R.id.index_sp, 5);
		TAB4And5Map.put(R.id.index_ftse, 5);
		TAB4And5Map.put(R.id.index_cac, 5);
		TAB4And5Map.put(R.id.index_dax, 5);
	}

	private Handler								UIUpdater									= new Handler()
																						{
																							@Override
																							public void handleMessage(
																									Message msg)
																							{
																								switch (msg.what)
																								{
																									case INFO_CONTENT_UPDATE:
																										if (msg.arg1 < 0)
																											IndexUIUpdate(
																													msg.obj,
																													false);
																										else
																											IndexUIUpdate(
																													msg.obj,
																													true);
																										break;
																								}
																							}
																						};

	private final Object							lockObject								= new Object();

	private void IndexUIUpdate(Object iHandlerObj, boolean iBlink)
	{
		synchronized (lockObject)
		{
			if (!(iHandlerObj instanceof DoThingsReturn))
				return;

			TextView textViewObj;
			DoThingsReturn object = (DoThingsReturn) iHandlerObj;

			textViewObj = (TextView) object.data;
			if (textViewObj == null)
				return;

			textViewObj.setText(object.cmd.toString());
			if (!iBlink)
				return;

			final ViewGroup parent;

			// This is not a good way of the getting the holder. Our design
			// needs to be more rigid;
			parent = (ViewGroup) textViewObj.getParent().getParent()
					.getParent();
			if ((parent != null) && (parent.isShown()))
			{
				Animation animatAction = AnimationUtils.loadAnimation(
						_context, R.anim.just_delay);
				animatAction.setDuration(blinkTime);
				animatAction.setAnimationListener(new AnimationListener()
				{
					@Override
					public void onAnimationEnd(Animation animation)
					{
						// parent.setBackgroundColor(_context.getResources().getColor(android.R.color.transparent));
						parent.setBackgroundResource(R.drawable.backgound_states_4_index_and_fx);
					}

					@Override
					public void onAnimationRepeat(Animation animation)
					{
					}

					@Override
					public void onAnimationStart(Animation animation)
					{
					}
				});
				parent.setBackgroundColor(_context.getResources().getColor(
						R.color.blue));
				parent.setAnimation(animatAction);
				animatAction.startNow();
				parent.invalidate();
				// parent.startAnimation(animatAction);
			}
		}
	}

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		TDStockLog.d(TAG, "created");
		_context = this;

		this.setContentView(R.layout.index);

		initHasChartList();// by zhengan

		/*
		 * _streamerTimeoutHandler = new StreamerTimeoutHandler(this,
		 * _messageHandler);
		 */
		resetMinHeightOnWorkCenter();
		_formater = DecimalFormat.getInstance();
		_formater.setMaximumFractionDigits(0);
		// _formater.setMinimumFractionDigits(2);

		/*
		 * _toolbutton_options =
		 * (ImageView)findViewById(R.id.toolbutton_options);
		 * _toolbutton_options.setFocusable(true);
		 * _toolbutton_options.setClickable(true);
		 * _toolbutton_options.setOnClickListener(new
		 * DefaultClickHandler(this));
		 */

		_top_bar_title = (TextView) findViewById(R.id.top_bar_title);

		_toolbutton_options = (Button) findViewById(R.id.options_btn);
		// _toolbutton_options.setOnClickListener(new
		// DefaultClickHandler(this));
		_toolbutton_options.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				TDStockLog.d(TAG,
						"close current activity and forwarding to the previous");
				/*
				 * Intent intent =new
				 * Intent(getApplicationContext(),IndexOptionsListActivity
				 * .class);
				 * intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
				 * startActivity(intent);
				 */

				Intent intent = new Intent(getApplicationContext(),
						IndexOptionsListActivity.class);
				intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
						| Intent.FLAG_ACTIVITY_NO_USER_ACTION);
				/*
				 * View currView = IndexGroup.group.getLocalActivityManager()
				 * .startActivity( IndexOptionsListActivity.class
				 * .getSimpleName(), intent) .getDecorView();
				 * IndexGroup.group.setContentView(currView); //modified by
				 * haibo, 2011-05-16
				 */

				SwitchForwardActivity(IndexOptionsListActivity.class,
						intent);

			}

		});

		initTabButtons();

		// "期指Futures"，"上証SSEI" set Adapter
		initFuturesAndSSEIAdapterType();
		initIndexViews();
		isChangeModeType = false;
	}

	public static boolean	isChangeModeType		= false;
	/*-----------------by ouyangzhihui 2011-08-24-------------------*/
	protected static String	_indexFuturesAdapter	= IndexFuturesInfo.ADAPTER;
	protected static String	_indexSSEIAdapter		= WorldIndexDelayInfo.ADAPTER;

	private void initFuturesAndSSEIAdapterType()
	{
		/* "期指"2 (account login && svcPlan=1) || activeCode login */
		if ((((ITDLApplication) getApplicationContext())
				.getIsRealtimeFutures() && ((ITDLApplication) getApplicationContext())
				.getModeType() == CommonDefn.ModeType.ACCOUNTLOGIN)
				|| ((ITDLApplication) getApplicationContext())
						.getModeType() == CommonDefn.ModeType.ACTIVECODE)
		{
			// 實時數據
			_indexFuturesAdapter = IndexFuturesInfo.adapter_realtime;
		}
		else
		{
			_indexFuturesAdapter = IndexFuturesInfo.adapter_delay;
		}

		/* "上証"5 (account login && svcPlan=1) || activeCode login */
		if ((((ITDLApplication) getApplicationContext()).getIsRealtimeSSEI() && ((ITDLApplication) getApplicationContext())
				.getModeType() == CommonDefn.ModeType.ACCOUNTLOGIN)
				|| ((ITDLApplication) getApplicationContext())
						.getModeType() == CommonDefn.ModeType.ACTIVECODE)
		{
			// 實時數據
			_indexSSEIAdapter = WorldIndexInfo.ADAPTER;
		}
		else
		{
			_indexSSEIAdapter = WorldIndexDelayInfo.ADAPTER;
		}
	}

	/*-----------------by ouyangzhihui 2011-08-24-------------------*/

	private void subscriteIndex()
	{
		try
		{

			/*
			 * _myClient = ((ITDLApplication) getApplicationContext())
			 * .getLightStreamerClient();
			 */

			List<String> iIdList = new ArrayList<String>();
			List<LS_SubscriptionItem> iItemList = new ArrayList<LS_SubscriptionItem>();
			List<ILS_UserClient_Response> iResponseList = new ArrayList<ILS_UserClient_Response>();

			/*
			 * _subscrRefs.addAll(Arrays.asList(subscribeMultiple( _myClient,
			 * INDEX_TELETEXT_ALL_ITEMS, new String[] { IndexInfo.INDEXLAST,
			 * IndexInfo.INDEXNET, IndexInfo.INDEXHIGH, IndexInfo.INDEXLOW,
			 * IndexInfo.INDEXOPEN, IndexInfo.INDEXPREV, IndexInfo.TURNOVER,
			 * IndexInfo.INDEXNETPRECENTAGE }, IndexInfo.ADAPTER,
			 * _lightStreamerHandlerOnIndex)));
			 */

			{
				if (_lightStreamerHandlerOnIndex == null)
				{
					_lightStreamerHandlerOnIndex = new LightStreamerHandlerOnIndex();
				}

				LS_SubscriptionItem interestItem = new LS_SubscriptionItem(
						IndexInfo.ADAPTER);
				for (String item : INDEX_TELETEXT_ALL_ITEMS)
					interestItem.AddSubscribeItem(item);

				interestItem.AddSubscribeSchema(IndexInfo.INDEXLAST);
				interestItem.AddSubscribeSchema(IndexInfo.INDEXNET);
				interestItem.AddSubscribeSchema(IndexInfo.INDEXHIGH);
				interestItem.AddSubscribeSchema(IndexInfo.INDEXLOW);
				interestItem.AddSubscribeSchema(IndexInfo.INDEXOPEN);
				interestItem.AddSubscribeSchema(IndexInfo.INDEXPREV);
				interestItem.AddSubscribeSchema(IndexInfo.TURNOVER);
				interestItem
						.AddSubscribeSchema(IndexInfo.INDEXNETPRECENTAGE);

				/*
				 * IDENTIFIER_0 = LSGetUniqueID(); if
				 * (LightStreamerSubscribeItem(IDENTIFIER_0, interestItem,this))
				 * {
				 * 
				 * }
				 */

				iIdList.add(IDENTIFIER_0);
				iItemList.add(interestItem);
				iResponseList.add(this);

			}

			{
				if (_lightStreamerHandlerOnWorldIndex == null)
				{
					_lightStreamerHandlerOnWorldIndex = new LightStreamerHandlerOnWorldIndex();
				}

				LS_SubscriptionItem interestItem = new LS_SubscriptionItem(
						WorldIndexInfo.ADAPTER);
				// for(String item: WORLD_INDEX_ITEMS)
				interestItem.SetSubscribeItem(WORLD_INDEX_ITEMS);

				interestItem.AddSubscribeSchema(WorldIndexInfo.LAST);
				interestItem.AddSubscribeSchema(WorldIndexInfo.NET);
				interestItem.AddSubscribeSchema(WorldIndexInfo.HIGH);
				interestItem.AddSubscribeSchema(WorldIndexInfo.LOW);
				interestItem.AddSubscribeSchema(WorldIndexInfo.OPEN);
				interestItem.AddSubscribeSchema(WorldIndexInfo.PREV);
				interestItem.AddSubscribeSchema(WorldIndexInfo.VOL);
				interestItem
						.AddSubscribeSchema(WorldIndexInfo.NETPERCENTAGE);

				/*
				 * IDENTIFIER_1 = LSGetUniqueID(); if
				 * (LightStreamerSubscribeItem(IDENTIFIER_1, interestItem,this))
				 * {
				 * 
				 * }
				 */

				iIdList.add(IDENTIFIER_1);
				iItemList.add(interestItem);
				iResponseList.add(this);

			}

			TDStockLog.d(TAG, "enter ::subscriteIndex -1");

			// Thread.yield();

			/*
			 * _subscrRefs.addAll(Arrays.asList(subscribeMultiple( _myClient,
			 * INDEX_FUTURES_ITEMS, new String[] {
			 * IndexFuturesInfo.CURRENTINDEX, IndexFuturesInfo.LAST,
			 * IndexFuturesInfo.NET, IndexFuturesInfo.HIGH,
			 * IndexFuturesInfo.LOW, IndexFuturesInfo.OPEN,
			 * IndexFuturesInfo.PREV, IndexFuturesInfo.MM, IndexFuturesInfo.VOL,
			 * IndexFuturesInfo.NETPRECENTAGE }, IndexFuturesInfo.ADAPTER,
			 * _lightStreamerHandlerOnIndexFutures)));
			 */
			// Thread.sleep(250);

			{

				if (_lightStreamerHandlerOnIndexFutures == null)
				{
					_lightStreamerHandlerOnIndexFutures = new LightStreamerHandlerOnIndexFutures();
				}

				LS_SubscriptionItem interestItem = new LS_SubscriptionItem(
				/* IndexFuturesInfo.ADAPTER */_indexFuturesAdapter);
				for (String item : INDEX_FUTURES_ITEMS)
					interestItem.AddSubscribeItem(item);

				interestItem.AddSubscribeSchema(IndexFuturesInfo.LAST);
				interestItem.AddSubscribeSchema(IndexFuturesInfo.NET);
				interestItem.AddSubscribeSchema(IndexFuturesInfo.HIGH);
				interestItem.AddSubscribeSchema(IndexFuturesInfo.LOW);
				interestItem.AddSubscribeSchema(IndexFuturesInfo.OPEN);
				interestItem.AddSubscribeSchema(IndexFuturesInfo.PREV);
				interestItem.AddSubscribeSchema(IndexFuturesInfo.MM);
				interestItem.AddSubscribeSchema(IndexFuturesInfo.VOL);
				interestItem
						.AddSubscribeSchema(IndexFuturesInfo.NETPRECENTAGE);

				/*
				 * IDENTIFIER_2 = LSGetUniqueID(); if
				 * (LightStreamerSubscribeItem(IDENTIFIER_2, interestItem,this))
				 * {
				 * 
				 * }
				 */

				iIdList.add(IDENTIFIER_2);
				iItemList.add(interestItem);
				iResponseList.add(this);

			}

			TDStockLog.d(TAG, "enter ::subscriteIndex -2");
			{

				if (_lightStreamerHandlerOnWorldIndexDelayRealtime == null)
				{
					_lightStreamerHandlerOnWorldIndexDelayRealtime = new LightStreamerHandlerOnWorldIndexDelayRealtime();
				}

				LS_SubscriptionItem interestItem = new LS_SubscriptionItem(
						_indexSSEIAdapter);
				// for(String item: WORLD_INDEX_ITEMS_DELAY_AND_REALTIME)
				interestItem
						.SetSubscribeItem(WORLD_INDEX_ITEMS_DELAY_AND_REALTIME);

				interestItem.AddSubscribeSchema(WorldIndexInfo.LAST);
				interestItem.AddSubscribeSchema(WorldIndexInfo.NET);
				interestItem.AddSubscribeSchema(WorldIndexInfo.HIGH);
				interestItem.AddSubscribeSchema(WorldIndexInfo.LOW);
				interestItem.AddSubscribeSchema(WorldIndexInfo.OPEN);
				interestItem.AddSubscribeSchema(WorldIndexInfo.PREV);
				interestItem.AddSubscribeSchema(WorldIndexInfo.VOL);
				interestItem
						.AddSubscribeSchema(WorldIndexInfo.NETPERCENTAGE);

				iIdList.add(IDENTIFIER_5);
				iItemList.add(interestItem);
				iResponseList.add(this);

				/*
				 * _subscrRefs.addAll(Arrays.asList(subscribeMultiple(
				 * _myClient, WORLD_INDEX_ITEMS_DELAY_AND_REALTIME, new String[]
				 * { WorldIndexInfo.LAST, WorldIndexInfo.NET,
				 * WorldIndexInfo.HIGH, WorldIndexInfo.LOW, WorldIndexInfo.OPEN,
				 * WorldIndexInfo.PREV, WorldIndexInfo.VOL,
				 * WorldIndexInfo.NETPERCENTAGE}, _indexSSEIAdapter,
				 * _lightStreamerHandlerOnWorldIndexDelayRealtime)));
				 * Thread.currentThread().yield();
				 */
			}

			TDStockLog.d(TAG, "enter ::subscriteIndex -3");

			// Thread.yield();

			/*
			 * _subscrRefs.addAll(Arrays.asList(subscribeMultiple( _myClient,
			 * WORLD_INDEX_ITEMS, new String[] { WorldIndexInfo.LAST,
			 * WorldIndexInfo.NET, WorldIndexInfo.HIGH, WorldIndexInfo.LOW,
			 * WorldIndexInfo.OPEN, WorldIndexInfo.PREV, WorldIndexInfo.VOL,
			 * WorldIndexInfo.NETPERCENTAGE}, WorldIndexInfo.ADAPTER,
			 * _lightStreamerHandlerOnWorldIndex)));
			 */
			// Thread.sleep(250);

			TDStockLog.d(TAG, "enter ::subscriteIndex -2");
			// Thread.yield();

			/*
			 * _subscrRefs.addAll(Arrays.asList(subscribeMultiple( _myClient,
			 * WORLD_FUTURES_ITEMS, new String[] { WorldFuturesInfo.NAME,
			 * WorldFuturesInfo.LAST, WorldFuturesInfo.NET,
			 * WorldFuturesInfo.HIGH, WorldFuturesInfo.LOW,
			 * WorldFuturesInfo.OPEN, WorldFuturesInfo.MM },
			 * WorldFuturesInfo.ADAPTER, _lightStreamerHandlerOnWorldFutures)));
			 */

			{

				if (_lightStreamerHandlerOnWorldFutures == null)
				{
					_lightStreamerHandlerOnWorldFutures = new LightStreamerHandlerOnWorldFutures();
				}

				LS_SubscriptionItem interestItem = new LS_SubscriptionItem(
						WorldFuturesInfo.ADAPTER);
				for (String item : WORLD_FUTURES_ITEMS)
					interestItem.AddSubscribeItem(item);

				interestItem.AddSubscribeSchema(WorldFuturesInfo.NAME);
				interestItem.AddSubscribeSchema(WorldFuturesInfo.LAST);
				interestItem.AddSubscribeSchema(WorldFuturesInfo.NET);
				interestItem.AddSubscribeSchema(WorldFuturesInfo.HIGH);
				interestItem.AddSubscribeSchema(WorldFuturesInfo.LOW);
				interestItem.AddSubscribeSchema(WorldFuturesInfo.OPEN);
				interestItem.AddSubscribeSchema(WorldFuturesInfo.MM);

				/*
				 * IDENTIFIER_3 = LSGetUniqueID(); if
				 * (LightStreamerSubscribeItem(IDENTIFIER_3, interestItem,this))
				 * {
				 * 
				 * }
				 */

				iIdList.add(IDENTIFIER_3);
				iItemList.add(interestItem);
				iResponseList.add(this);

			}

			// Thread.sleep(250);

			TDStockLog.d(TAG, "enter ::subscriteIndex -4");

			// _subscrRefs.add(subscribeItems(_myClient,WORLD_INDEX_DELAY_ITEMS,
			// new String[] {WorldIndexDelayInfo.LAST, WorldIndexDelayInfo.NET,
			// WorldIndexDelayInfo.HIGH, WorldIndexDelayInfo.LOW,
			// WorldIndexDelayInfo.OPEN, WorldIndexDelayInfo.PREV,
			// WorldIndexDelayInfo.VOL}, WorldIndexDelayInfo.ADAPTER,
			// new LightStreamerHandlerOnWorldIndexDelay()));

			// Thread.yield();

			/*
			 * _subscrRefs.addAll(Arrays.asList(subscribeMultiple( _myClient,
			 * WORLD_INDEX_DELAY_ITEMS, new String[] { WorldIndexDelayInfo.LAST,
			 * WorldIndexDelayInfo.NET, WorldIndexDelayInfo.HIGH,
			 * WorldIndexDelayInfo.LOW, WorldIndexDelayInfo.OPEN,
			 * WorldIndexDelayInfo.PREV, WorldIndexDelayInfo.VOL,
			 * WorldIndexDelayInfo.NETPERCENTAGE}, WorldIndexDelayInfo.ADAPTER,
			 * _lightStreamerHandlerOnWorldIndexDelay)));
			 */

			{

				if (_lightStreamerHandlerOnWorldIndexDelay == null)
				{
					_lightStreamerHandlerOnWorldIndexDelay = new LightStreamerHandlerOnWorldIndexDelay();
				}

				LS_SubscriptionItem interestItem = new LS_SubscriptionItem(
						WorldIndexDelayInfo.ADAPTER);
				for (String item : WORLD_INDEX_DELAY_ITEMS)
					interestItem.AddSubscribeItem(item);

				interestItem.AddSubscribeSchema(WorldIndexDelayInfo.LAST);
				interestItem.AddSubscribeSchema(WorldIndexDelayInfo.NET);
				interestItem.AddSubscribeSchema(WorldIndexDelayInfo.HIGH);
				interestItem.AddSubscribeSchema(WorldIndexDelayInfo.LOW);
				interestItem.AddSubscribeSchema(WorldIndexDelayInfo.OPEN);
				interestItem.AddSubscribeSchema(WorldIndexDelayInfo.PREV);
				interestItem.AddSubscribeSchema(WorldIndexDelayInfo.VOL);
				interestItem
						.AddSubscribeSchema(WorldIndexDelayInfo.NETPERCENTAGE);

				/*
				 * IDENTIFIER_4 = LSGetUniqueID(); if
				 * (LightStreamerSubscribeItem(IDENTIFIER_4, interestItem,this))
				 * {
				 * 
				 * }
				 */

				iIdList.add(IDENTIFIER_4);
				iItemList.add(interestItem);
				iResponseList.add(this);

			}

			LightStreamerSubscribeItemsInBatch(iIdList, iItemList,
					iResponseList);

			TDStockLog.d(TAG, "add  Items!");

			_isSubscribed = true;

			// TDStockLog.d(TAG, "Size of subscribition  after Subscribed: " +
			// this._subscrRefs.size() );
		}

		catch (Exception e)
		{

			TDStockLog.e(
					TAG,
					"other exception!"
							+ (e.getMessage() == null ? "unkonwn Exception!"
									: e.getMessage()));
			handleLightStreamerException(e);
		}
	}

	private class LightStreamerHandlerOnIndex implements
		LightStreamerHandlerInterface
	{
		// private DoThingsReturn updateWrapper;
		// private ColorRefreshTask refresh;
		public void onUpdate(final int itemPos, final String itemName,
				final UpdateInfo update)
		{
			if (_isInBackground)
			{
				Thread.yield();
				return;
			}

			final Runnable myUpdateResults = new Runnable()
			{
				public void run()
				{
					final String last = update
							.getNewValue(IndexInfo.INDEXLAST);
					String net = update.getNewValue(IndexInfo.INDEXNET);
					String high = update.getNewValue(IndexInfo.INDEXHIGH);
					String low = update.getNewValue(IndexInfo.INDEXLOW);
					String open = update.getNewValue(IndexInfo.INDEXOPEN);
					String prev = update.getNewValue(IndexInfo.INDEXPREV);
					String turnover = update
							.getNewValue(IndexInfo.TURNOVER);
					String netPrecentage = update
							.getNewValue(IndexInfo.INDEXNETPRECENTAGE);
					// DT, 2011/01/14, format to 0 d.p., need to be the same as
					// iPhone app
					net = StringUtils.formatToEitherDp(net, -10.0, 10.0,
							2, 0);
					if (open == null)
					{
						open = "0.00";
					}
					if (prev == null)
					{
						prev = "0.00";
					}
					if (turnover == null)
					{
						turnover = "0.00";
					}

					boolean isNegative = net.indexOf("-") >= 0;
					if (itemPos == 1 || itemPos == 2)
					{
						for (int index = 0; index < 2; index++)
						{
							if (usingBlinkColumn)
							{
								Message exMessage;
								TextView currentView;

								currentView = itemName
										.equals(INDEX_NAME_HSI) ? _index_hsi_views[index][0]
										: _index_hscei_views[index][0];

								exMessage = /* new Message(); */UIUpdater
										.obtainMessage();
								exMessage.what = INFO_CONTENT_UPDATE;
								exMessage.obj = new DoThingsReturn(
										/*
										 * last.subSequence(0, last.indexOf('.') >= 0 ?
										 * last.indexOf('.') : last.length()),
										 */
										last == null ? ""
												: StringUtils
														.formatScaleInteger(Double
																.parseDouble(last)),
										currentView, 0);
								exMessage.arg1 = 1;
								UIUpdater.sendMessage(exMessage);
							}
							else
							{
								final TextView currentView = itemName
										.equals(INDEX_NAME_HSI) ? _index_hsi_views[index][0]
										: _index_hscei_views[index][0];
								new Thread()
								{
									public void run()
									{
										DoThingsReturn updateWrapper = new DoThingsReturn(
												/*
												 * last.subSequence(0,
												 * last.indexOf('.') >= 0 ?
												 * last.indexOf('.') :
												 * last.length()),
												 */
												last == null ? ""
														: StringUtils
																.formatScaleInteger(Double
																		.parseDouble(last)),
												currentView, 0);
										ColorRefreshTask refresh = new ColorRefreshTask(
												IndexActivity.this,
												CommonDefn.HIGHLIGHT_BACKGROUND_COLOR_INDEX,
												updateWrapper);
										if (updateWrapper == null)
										{
											updateWrapper = new DoThingsReturn(
													null, null, 0);
										}
										updateWrapper.cmd = last
												.subSequence(
														0,
														last.indexOf('.') >= 0 ? last
																.indexOf('.')
																: last.length());
										updateWrapper.data = currentView;
										updateWrapper.errCode = 0;

										if (refresh == null)
										{
											refresh = new ColorRefreshTask(
													IndexActivity.this,
													CommonDefn.HIGHLIGHT_BACKGROUND_COLOR_INDEX,
													updateWrapper);
										}
										refresh.setRefreshObj(updateWrapper);
										// refresh = new
										// ColorRefreshTask(IndexActivity.this,CommonDefn.HIGHLIGHT_BACKGROUND_COLOR_INDEX,
										// updateWrapper);*/
										_messageHandler.postDelayed(
												refresh, 50);
									}
								}.start();
								// currentView.setText(last.subSequence(0,
								// last.indexOf('.') >= 0 ? last.indexOf('.') :
								// last.length()));
								// modified by haibo, 2011-06-20, no need to do
								// so and it cause the anr.
								// //currentView.postInvalidate();
							}
							{
								try
								{
									TextView currentView = itemName
											.equals(INDEX_NAME_HSI) ? _index_hsi_views[index][1]
											: _index_hscei_views[index][1];
									net = StringUtils.formatString(
											net, isNegative ? null
													: "+", null);
									currentView.setText(net);
									currentView
											.setTextColor(isNegative ? Color.RED
													: Color.GREEN);
									// modified by haibo, 2011-06-20, no need to
									// do so and it cause the anr.
									// currentView.postInvalidate();
								}
								catch (Exception e)
								{
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
							}
							{
								try
								{
									TextView currentView = itemName
											.equals(INDEX_NAME_HSI) ? _index_hsi_views[index][2]
											: _index_hscei_views[index][2];
									/*
									 * net_percentage = StringUtils
									 * .formatString( net_percentage, isNegative
									 * ? null : "+", null);
									 */
									if (!netPrecentage.contains("%"))
										netPrecentage = StringUtils
												.formatNumberByNetPerectage(
														netPrecentage,
														4);
									currentView.setText(netPrecentage);
									currentView
											.setTextColor(isNegative ? Color.RED
													: Color.GREEN);
									// modified by haibo, 2011-06-20, no need to
									// do so and it cause the anr.
									// currentView.postInvalidate();
								}
								catch (Exception e)
								{
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
							}
							{
								try
								{
									TextView currentView = itemName
											.equals(INDEX_NAME_HSI) ? _index_hsi_views[index][3]
											: _index_hscei_views[index][3];
									currentView
											.setText(high
													.subSequence(
															0,
															high.indexOf('.') >= 0 ? high
																	.indexOf('.')
																	: high.length()));
									// modified by haibo, 2011-06-20, no need to
									// do so and it cause the anr.
									// currentView.postInvalidate();
								}
								catch (Exception e)
								{
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
							}

							{
								try
								{
									TextView currentView = itemName
											.equals(INDEX_NAME_HSI) ? _index_hsi_views[index][4]
											: _index_hscei_views[index][4];
									currentView
											.setText(low
													.subSequence(
															0,
															low.indexOf('.') >= 0 ? low
																	.indexOf('.')
																	: low.length()));
									// modified by haibo, 2011-06-20, no need to
									// do so and it cause the anr.
									// currentView.postInvalidate();
								}
								catch (Exception e)
								{
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
							}
							{
								try
								{
									TextView currentView = itemName
											.equals(INDEX_NAME_HSI) ? _index_hsi_views[index][5]
											: _index_hscei_views[index][5];
									currentView
											.setText(open
													.subSequence(
															0,
															open.indexOf('.') >= 0 ? open
																	.indexOf('.')
																	: open.length()));
									// modified by haibo, 2011-06-20, no need to
									// do so and it cause the anr.
									// currentView.postInvalidate();
								}
								catch (Exception e)
								{
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
							}

							if (itemName.equals(INDEX_NAME_HSI))
							{
								try
								{
									_index_hsi_views[index][6]
											.setText(/*
													 * _formater .format(Double
													 * .parseDouble(turnover) /
													 * 100000.00d)
													 */StringUtils
													.roundDownInteger(String
															.valueOf(Double
																	.parseDouble(turnover) / 100000.00d))
													+ getResources()
															.getString(
																	R.string.a_hundred_million));
									// modified by haibo, 2011-06-20, no need to
									// do so and it cause the anr.
									// _index_hsi_views[index][6].postInvalidate();
								}
								catch (NumberFormatException e)
								{
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
								catch (NotFoundException e)
								{
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
							}
							else if (itemName.equals(INDEX_NAME_HSCEI))
							{
								try
								{
									_index_hscei_views[index][6]
											.setText(
											/*
											 * prev.subSequence(0, prev.indexOf('.') >=
											 * 0 ? prev.indexOf('.') : prev.length())
											 */
											StringUtils
													.formatScaleInteger(Double
															.parseDouble(prev)));
								}
								catch (Exception e)
								{
									e.printStackTrace();
								}
							}
						}
					}
					else
					{
						{
							try
							{
								TextView currentView = _index_category[itemPos - 3][0];
								currentView
										.setText(
										/*
										 * last.subSequence(0, last.indexOf('.') >= 0 ?
										 * last.indexOf('.') : last.length())
										 */
										last == null ? ""
												: StringUtils
														.formatScaleInteger(Double
																.parseDouble(last)));
							}
							catch (Exception e)
							{
								e.printStackTrace();
							}
						}
						{
							try
							{
								TextView currentView = _index_category[itemPos - 3][1];
								net = StringUtils
										.formatString(net,
												isNegative ? null
														: "+",
												null);
								currentView.setText(net);
								currentView
										.setTextColor(isNegative ? Color.RED
												: Color.GREEN);
								// modified by haibo, 2011-06-20, no need to do
								// so and it cause the anr.
								// currentView.postInvalidate();
							}
							catch (Exception e)
							{
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
						}
						{
							try
							{
								TextView currentView = _index_category[itemPos - 3][2];
								/*
								 * net_percentage = StringUtils
								 * .formatString(net_percentage, isNegative ?
								 * null : "+", null);
								 */
								if (!netPrecentage.contains("%"))
									netPrecentage = StringUtils
											.formatNumberByNetPerectage(
													netPrecentage,
													4);
								currentView.setText(netPrecentage);
								currentView
										.setTextColor(isNegative ? Color.RED
												: Color.GREEN);
								// modified by haibo, 2011-06-20, no need to do
								// so and it cause the anr.
								// currentView.postInvalidate();
							}
							catch (Exception e)
							{
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
						}
						{
							try
							{
								TextView currentView = _index_category[itemPos - 3][3];
								currentView.setText(high.subSequence(
										0,
										high.indexOf('.') >= 0 ? high
												.indexOf('.')
												: high.length()));
								// modified by haibo, 2011-06-20, no need to do
								// so and it cause the anr.
								// currentView.postInvalidate();
							}
							catch (Exception e)
							{
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
						}
						{
							try
							{
								TextView currentView = _index_category[itemPos - 3][4];
								currentView.setText(low.subSequence(
										0,
										low.indexOf('.') >= 0 ? low
												.indexOf('.') : low
												.length()));
								// modified by haibo, 2011-06-20, no need to do
								// so and it cause the anr.
								// currentView.postInvalidate();
							}
							catch (Exception e)
							{
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
						}
						{
							try
							{
								TextView currentView = _index_category[itemPos - 3][5];
								currentView.setText(open.subSequence(
										0,
										open.indexOf('.') >= 0 ? open
												.indexOf('.')
												: open.length()));
								// modified by haibo, 2011-06-20, no need to do
								// so and it cause the anr.
								// currentView.postInvalidate();
							}
							catch (Exception e)
							{
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
						}
						{
							try
							{
								TextView currentView = _index_category[itemPos - 3][6];
								currentView.setText(
								/*
								 * prev.subSequence(0, prev.indexOf('.') >= 0 ?
								 * prev.indexOf('.') : prev.length())
								 */
								StringUtils.formatScaleInteger(Double
										.parseDouble(prev)));
							}
							catch (Exception e)
							{
								e.printStackTrace();
							}
						}
					}
				}
			};

			new Thread()
			{
				public void run()
				{
					_messageHandler.post(myUpdateResults);
				}
			}.start();
		}
	}

	private class LightStreamerHandlerOnWorldIndexDelay implements
		LightStreamerHandlerInterface
	{
		public void onUpdate(final int itemPos, final String itemName,
				final UpdateInfo update)
		{
			if (_isInBackground)
			{
				Thread.yield();
				return;
			}
			try
			{
				onUpdateWorldIndexDelay(itemPos, itemName, update);
			}
			catch (Exception e)
			{
				// TODO Auto-generated catch block
				TDStockLog.d(
						TAG,
						"insert result:" + e.getMessage() == null ? "unknown exception!"
								: e.getMessage());
			}
		}
	}

	private class LightStreamerHandlerOnWorldIndexDelayRealtime implements
		LightStreamerHandlerInterface
	{
		public void onUpdate(final int itemPos, final String itemName,
				final UpdateInfo update)
		{
			if (_isInBackground)
			{
				Thread.yield();
				return;
			}
			try
			{
				onUpdateWorldIndexDelayRealtime(itemPos, itemName, update);
			}
			catch (Exception e)
			{
				TDStockLog.d(
						TAG,
						"insert result:" + e.getMessage() == null ? "unknown exception!"
								: e.getMessage());
			}
		}
	}

	private void onUpdateWorldIndexDelayRealtime(final int itemPos,
			final String itemName, final UpdateInfo update)
	{
		final Runnable myUpdateResults = new Runnable()
		{
			public void run()
			{
				// WorldIndexInfo.Last, WorldIndexInfo.Net, WorldIndexInfo.High,
				// WorldIndexInfo.Low, WorldIndexInfo.Open, WorldIndexInfo.Prev,
				// WorldIndexInfo.Vol
				final String last = update.getNewValue(WorldIndexInfo.LAST);
				String net = update.getNewValue(WorldIndexInfo.NET);
				String net_percentage = update
						.getNewValue(WorldIndexInfo.NETPERCENTAGE);
				String high = update.getNewValue(WorldIndexInfo.HIGH);
				String low = update.getNewValue(WorldIndexInfo.LOW);
				String open = update.getNewValue(WorldIndexInfo.OPEN);
				String prev = update.getNewValue(WorldIndexInfo.PREV);
				String vol = update.getNewValue(WorldIndexInfo.VOL);

				// DT, 2011/01/14, format to 0 d.p., need to be the same as
				// iPhone app
				net = StringUtils.formatToEitherDp(net, -10.0, 10.0, 2, 0);

				if (last == null || net == null)
				{
					return;
				}

				net_percentage = StringUtils
						.formatToFiveCharsRule(net_percentage) + "%";

				boolean isNegative = net.indexOf("-") >= 0;

				TextView[] holder = _world_index_delay_realtime_views[itemPos - 1];

				if (usingBlinkColumn)
				{
					Message exMessage;
					TextView currentView;

					currentView = holder[0];

					exMessage = /* new Message(); */UIUpdater
							.obtainMessage();
					exMessage.what = INFO_CONTENT_UPDATE;
					exMessage.obj = new DoThingsReturn(
					/*
					 * last.subSequence(0,last.indexOf('.') >= 0 ?
					 * last.indexOf('.') : last.length()),
					 */
					last == null ? ""
							: StringUtils.formatScaleInteger(Double
									.parseDouble(last)), currentView,
							0);
					exMessage.arg1 = 1;
					UIUpdater.sendMessage(exMessage);

					TDStockLog.d(TAG, "update view 0 successfully!");

				}
				else
				{
					final TextView currentView = holder[0];
					// currentView.setText(last.subSequence(0, last.indexOf('.')
					// >= 0 ? last.indexOf('.') : last.length()));
					// modified by haibo, 2011-06-20, no need to do so and it
					// cause the anr. //currentView.postInvalidate();
					new Thread()
					{
						public void run()
						{
							DoThingsReturn updateWrapper = new DoThingsReturn(
									/*
									 * last.subSequence(0, last.indexOf('.') >= 0 ?
									 * last.indexOf('.') : last.length()),
									 */
									last == null ? ""
											: StringUtils
													.formatScaleInteger(Double
															.parseDouble(last)),
									currentView, 0);
							ColorRefreshTask refresh = new ColorRefreshTask(
									IndexActivity.this,
									CommonDefn.HIGHLIGHT_BACKGROUND_COLOR_INDEX,
									updateWrapper);
							_messageHandler.postDelayed(refresh, 50);
						}
					}.start();
				}
				{
					TextView currentView = holder[1];
					try
					{
						net = StringUtils.formatString(net,
								isNegative ? null : "+", null);
						currentView.setText(net);
						currentView.setTextColor(isNegative ? Color.RED
								: Color.GREEN);
						TDStockLog.d(TAG, "update view1 successfully!");
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						TDStockLog.d(TAG, "failed to update view1");
						e.printStackTrace();
					}
				}
				{
					TextView currentView = holder[2];
					try
					{
						net_percentage = StringUtils.formatString(
								net_percentage,
								isNegative ? null : "+", null);
						currentView.setText(net_percentage);
						currentView.setTextColor(isNegative ? Color.RED
								: Color.GREEN);
						TDStockLog.d(TAG, "update view2 successfully!");
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						TDStockLog.d(TAG, "failed to update view2");
						e.printStackTrace();
					}
				}
				{
					try
					{
						TextView currentView = holder[3];
						if (high != null)
						{
							currentView.setText(high.subSequence(
									0,
									high.indexOf(".") >= 0 ? high
											.indexOf(".") : high
											.length()));
							TDStockLog.d(TAG,
									"update view3 successfully!");
						}
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						TDStockLog.d(TAG, "failed to update view3");
						e.printStackTrace();
					}
				}
				{
					try
					{
						TextView currentView = holder[4];
						if (low != null)
						{
							currentView.setText(low.subSequence(
									0,
									low.indexOf(".") >= 0 ? low
											.indexOf(".") : low
											.length()));
							TDStockLog.d(TAG,
									"update view4 successfully!");
						}
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						TDStockLog.d(TAG, "failed to update view4");
						e.printStackTrace();
					}
				}
				{
					try
					{
						TextView currentView = holder[5];
						if (open != null)
						{
							currentView.setText(open.subSequence(
									0,
									open.indexOf(".") >= 0 ? open
											.indexOf(".") : open
											.length()));
							TDStockLog.d(TAG,
									"update view5 successfully!");
						}
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						TDStockLog.d(TAG, "failed to update view5");
						e.printStackTrace();
					}
				}

				if (itemPos != 1)
				{
					try
					{
						TextView currentView = holder[6];
						if (prev != null)
						{
							currentView.setText(prev.subSequence(
									0,
									prev.indexOf(".") >= 0 ? prev
											.indexOf(".") : prev
											.length()));
							TDStockLog.d(TAG,
									"update view6 successfully!");
						}
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						TDStockLog.d(TAG, "failed to update view6!");
						e.printStackTrace();
					}
				}
				else
				{
					try
					{
						TextView currentView = holder[6];
						((TextView) findViewById(R.id.index_preset_sse)
								.findViewWithTag(REPLACEMENT_TAG))
								.setText(R.string.index_sharetraded);
						// currentView.setText( _formater.format(
						// Double.parseDouble(vol) / 100000.00d ) +
						// getResources().getString(R.string.a_hundred_million));
						currentView
								.setText(/*
											 * _formater.format(Double
											 * .parseDouble(vol) /
											 * 100000000.00d)
											 */StringUtils.roundDownInteger(String.valueOf(Double
										.parseDouble(vol) / 100000000.00d))
										+ getResources()
												.getString(
														R.string.a_hundred_million));
						TDStockLog.d(TAG, "update view6 successfully!");
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (NumberFormatException e)
					{
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					catch (Exception e)
					{
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			}
		};

		new Thread()
		{
			public void run()
			{
				_messageHandler.post(myUpdateResults);
			}
		}.start();
	}

	private class LightStreamerHandlerOnWorldIndex implements
		LightStreamerHandlerInterface
	{
		public void onUpdate(final int itemPos, final String itemName,
				final UpdateInfo update)
		{
			if (_isInBackground)
			{
				Thread.yield();
				return;
			}
			try
			{
				onUpdateWorldIndex(itemPos, itemName, update);
			}
			catch (Exception e)
			{
				// TODO Auto-generated catch block
				TDStockLog.e(
						TAG,
						"onUpdateWorldIndex exception: "
								+ (e.getMessage() == null ? "unknown exception!"
										: e.getMessage()));
			}
		}
	}

	private void onUpdateWorldIndex(final int itemPos, final String itemName,
			final UpdateInfo update)
	{
		final Runnable myUpdateResults = new Runnable()
		{
			public void run()
			{
				// WorldIndexInfo.Last, WorldIndexInfo.Net, WorldIndexInfo.High,
				// WorldIndexInfo.Low, WorldIndexInfo.Open, WorldIndexInfo.Prev,
				// WorldIndexInfo.Vol
				final String last = update.getNewValue(WorldIndexInfo.LAST);
				String net = update.getNewValue(WorldIndexInfo.NET);
				String net_percentage = update
						.getNewValue(WorldIndexInfo.NETPERCENTAGE);
				String high = update.getNewValue(WorldIndexInfo.HIGH);
				String low = update.getNewValue(WorldIndexInfo.LOW);
				String open = update.getNewValue(WorldIndexInfo.OPEN);
				String prev = update.getNewValue(WorldIndexInfo.PREV);
				String vol = update.getNewValue(WorldIndexInfo.VOL);

				TDStockLog.d(
						TAG,
						String.format(
								"itemName= %s, itemPos = %d ,  net= %s, netPercentage=%s, high=%s, low=%s, open=%s, prev=%s, vol=%s",
								itemName, itemPos, net == null ? "null"
										: net,
								net_percentage == null ? "null"
										: net_percentage,
								high == null ? "null" : high,
								low == null ? "null" : low,
								open == null ? "null" : open,
								prev == null ? "null" : prev,
								vol == null ? "null" : vol));

				// DT, 2011/01/14, format to 0 d.p., need to be the same as
				// iPhone app
				net = StringUtils.formatToEitherDp(net, -10.0, 10.0, 2, 0);

				if (last == null || net == null)
				{
					return;
				}

				net_percentage = StringUtils
						.formatToFiveCharsRule(net_percentage) + "%";

				boolean isNegative = net.indexOf("-") >= 0;

				TextView[] holder = _world_index_views[itemPos - 1];
				if (usingBlinkColumn)
				{
					Message exMessage;
					TextView currentView;

					currentView = holder[0];

					exMessage = /* new Message(); */UIUpdater
							.obtainMessage();
					exMessage.what = INFO_CONTENT_UPDATE;
					exMessage.obj = new DoThingsReturn(
					/*
					 * last.subSequence(0,last.indexOf('.') >= 0 ?
					 * last.indexOf('.') : last.length()),
					 */
					last == null ? ""
							: StringUtils.formatScaleInteger(Double
									.parseDouble(last)), currentView,
							0);
					exMessage.arg1 = 1;
					UIUpdater.sendMessage(exMessage);
				}
				else
				{
					final TextView currentView = holder[0];
					// currentView.setText(last.subSequence(0, last.indexOf('.')
					// >= 0 ? last.indexOf('.') : last.length()));
					// modified by haibo, 2011-06-20, no need to do so and it
					// cause the anr. //currentView.postInvalidate();
					new Thread()
					{
						public void run()
						{
							DoThingsReturn updateWrapper = new DoThingsReturn(
									/*
									 * last.subSequence(0, last.indexOf('.') >= 0 ?
									 * last.indexOf('.') : last.length()),
									 */
									last == null ? ""
											: StringUtils
													.formatScaleInteger(Double
															.parseDouble(last)),
									currentView, 0);
							ColorRefreshTask refresh = new ColorRefreshTask(
									IndexActivity.this,
									CommonDefn.HIGHLIGHT_BACKGROUND_COLOR_INDEX,
									updateWrapper);
							_messageHandler.postDelayed(refresh, 50);
						}
					}.start();
				}
				{
					TextView currentView = holder[1];
					try
					{
						net = StringUtils.formatString(net,
								isNegative ? null : "+", null);
						currentView.setText(net);
						currentView.setTextColor(isNegative ? Color.RED
								: Color.GREEN);
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				{
					TextView currentView = holder[2];
					try
					{
						net_percentage = StringUtils.formatString(
								net_percentage,
								isNegative ? null : "+", null);
						currentView.setText(net_percentage);
						currentView.setTextColor(isNegative ? Color.RED
								: Color.GREEN);
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				{
					try
					{
						TextView currentView = holder[3];
						if (high != null)
						{
							currentView.setText(high.subSequence(
									0,
									high.indexOf(".") >= 0 ? high
											.indexOf(".") : high
											.length()));
						}
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				{
					try
					{
						TextView currentView = holder[4];
						if (low != null)
						{
							currentView.setText(low.subSequence(
									0,
									low.indexOf(".") >= 0 ? low
											.indexOf(".") : low
											.length()));
						}
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				{
					try
					{
						TextView currentView = holder[5];
						if (open != null)
						{
							currentView.setText(open.subSequence(
									0,
									open.indexOf(".") >= 0 ? open
											.indexOf(".") : open
											.length()));
						}
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}

				// if (itemPos != 1)
				// {
				try
				{
					TextView currentView = holder[6];
					if (prev != null)
					{
						currentView.setText(prev.subSequence(0, prev
								.indexOf(".") >= 0 ? prev.indexOf(".")
								: prev.length()));
					}
					// modified by haibo, 2011-06-20, no need to do so and it
					// cause the anr. currentView.postInvalidate();
				}
				catch (Exception e)
				{
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				// }
				// else
				// {
				// try
				// {
				// TextView currentView = holder[6];
				// ((TextView) findViewById(R.id.index_preset_sse)
				// .findViewWithTag(REPLACEMENT_TAG))
				// .setText(R.string.index_sharetraded);
				// //currentView.setText( _formater.format(
				// Double.parseDouble(vol) / 100000.00d ) +
				// getResources().getString(R.string.a_hundred_million));
				// currentView.setText(_formater.format(Double
				// .parseDouble(vol) / 100000000.00d)
				// + getResources().getString(
				// R.string.a_hundred_million));
				// // modified by haibo, 2011-06-20, no need to do so and it
				// cause the anr. currentView.postInvalidate();
				// }
				// catch (NumberFormatException e)
				// {
				// //TODO Auto-generated catch block
				// e.printStackTrace();
				// }
				// catch (Exception e)
				// {
				// //TODO Auto-generated catch block
				// e.printStackTrace();
				// }
				// }
			}
		};

		new Thread()
		{
			public void run()
			{
				_messageHandler.post(myUpdateResults);
			}
		}.start();
	}

	private void onUpdateWorldIndexDelay(final int itemPos,
			final String itemName, final UpdateInfo update)
	{
		if (_isInBackground)
		{
			return;
		}

		final Runnable myUpdateResults = new Runnable()
		{
			public void run()
			{
				final String last = update.getNewValue(WorldIndexInfo.LAST);
				String net = update.getNewValue(WorldIndexInfo.NET);
				String net_percentage = update
						.getNewValue(WorldIndexInfo.NETPERCENTAGE);
				String high = update.getNewValue(WorldIndexInfo.HIGH);
				String low = update.getNewValue(WorldIndexInfo.LOW);
				String open = update.getNewValue(WorldIndexInfo.OPEN);
				String prev = update.getNewValue(WorldIndexInfo.PREV);
				// String vol = update.getNewValue(WorldIndexInfo.Vol);

				// DT, 2011/01/14, format to 0 d.p., need to be the same as
				// iPhone app
				net = StringUtils.formatToEitherDp(net, -10.0, 10.0, 2, 0);

				if (last == null || net == null)
				{
					return;
				}

				net_percentage = StringUtils
						.formatToFiveCharsRule(net_percentage) + "%";
				/*
				 * String net_percentage = "0"; if
				 * (Math.abs(Double.parseDouble(last)) >
				 * CommonDefn.APPROACH_ZERO) { // DT, 2011/01/14, format to 2
				 * d.p., need to be the same as iPhone app //net_percentage =
				 * _formater.format( Double.parseDouble(net) /
				 * Double.parseDouble(last) * 100.00d) + "%"; net_percentage =
				 * StringUtils.formatToDp((Double .parseDouble(net) /
				 * Double.parseDouble(last) * 100.00d), 2) + "%"; }
				 */

				boolean isNegative = net.indexOf("-") >= 0;
				TextView[] holder = _worldIndex_delay[itemPos - 1];
				if (usingBlinkColumn)
				{
					Message exMessage;
					TextView currentView;

					currentView = holder[0];

					exMessage = /* new Message(); */UIUpdater
							.obtainMessage();
					exMessage.what = INFO_CONTENT_UPDATE;
					exMessage.obj = new DoThingsReturn(
					/*
					 * last.subSequence(0, last.indexOf('.') >= 0 ?
					 * last.indexOf('.') : last.length()),
					 */
					last == null ? ""
							: StringUtils.formatScaleInteger(Double
									.parseDouble(last)), currentView,
							0);
					exMessage.arg1 = 1;
					UIUpdater.sendMessage(exMessage);
				}
				else
				{
					final TextView currentView = holder[0];
					// currentView.setText(last.subSequence(0, last.indexOf('.')
					// >= 0 ? last.indexOf('.') : last.length()));
					// modified by haibo, 2011-06-20, no need to do so and it
					// cause the anr. //currentView.postInvalidate();

					new Thread()
					{
						public void run()
						{
							DoThingsReturn updateWrapper = new DoThingsReturn(
									/*
									 * last.subSequence(0, last.indexOf('.') >= 0 ?
									 * last.indexOf('.') : last.length()),
									 */
									last == null ? ""
											: StringUtils
													.formatScaleInteger(Double
															.parseDouble(last)),
									currentView, 0);
							ColorRefreshTask refresh = new ColorRefreshTask(
									IndexActivity.this,
									CommonDefn.HIGHLIGHT_BACKGROUND_COLOR_INDEX,
									updateWrapper);
							_messageHandler.postDelayed(refresh, 50);
						}
					}.start();
				}
				{
					TextView currentView = holder[1];
					try
					{
						net = StringUtils.formatString(net,
								isNegative ? null : "+", null);
						currentView.setText(net);
						currentView.setTextColor(isNegative ? Color.RED
								: Color.GREEN);
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				{
					TextView currentView = holder[2];
					try
					{
						net_percentage = StringUtils.formatString(
								net_percentage,
								isNegative ? null : "+", null);
						currentView.setText(net_percentage);
						currentView.setTextColor(isNegative ? Color.RED
								: Color.GREEN);
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				{
					try
					{
						TextView currentView = holder[3];
						currentView.setText(high.subSequence(0, high
								.indexOf(".") >= 0 ? high.indexOf(".")
								: high.length()));
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				{
					try
					{
						TextView currentView = holder[4];
						currentView.setText(low.subSequence(0, low
								.indexOf(".") >= 0 ? low.indexOf(".")
								: low.length()));
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				{
					try
					{
						TextView currentView = holder[5];
						currentView.setText(open.subSequence(0, open
								.indexOf(".") >= 0 ? open.indexOf(".")
								: open.length()));
						// modified by haibo, 2011-06-20, no need to do so and
						// it cause the anr. currentView.postInvalidate();
					}
					catch (Exception e)
					{
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}

				try
				{
					TextView currentView = holder[6];
					currentView.setText(prev.subSequence(0, prev
							.indexOf(".") >= 0 ? prev.indexOf(".")
							: prev.length()));
					// modified by haibo, 2011-06-20, no need to do so and it
					// cause the anr. currentView.postInvalidate();
				}
				catch (Exception e)
				{
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		};

		new Thread()
		{
			public void run()
			{
				_messageHandler.post(myUpdateResults);
			}
		}.start();
	}

	private void onUpdateIndexFutures(final int itemPos,
			final String itemName, final UpdateInfo update)
	{
		if (_isInBackground)
		{
			return;
		}

		final Runnable myUpdateResults = new Runnable()
		{
			public void run()
			{
				/*
				 * final String last =
				 * update.isValueChanged(IndexFuturesInfo.LAST) ?
				 * update.getNewValue(IndexFuturesInfo.LAST) :
				 * update.getOldValue(IndexFuturesInfo.LAST); String net =
				 * update.isValueChanged(IndexFuturesInfo.NET) ?
				 * update.getNewValue(IndexFuturesInfo.NET) :
				 * update.getOldValue(IndexFuturesInfo.NET); String mm =
				 * update.isValueChanged(IndexFuturesInfo.MM) ?
				 * update.getNewValue(IndexFuturesInfo.MM) :
				 * update.getOldValue(IndexFuturesInfo.MM);
				 */
				final String last = update
						.getNewValue(IndexFuturesInfo.LAST);
				String net = update.getNewValue(IndexFuturesInfo.NET);
				String netPrecentage = update
						.getNewValue(IndexFuturesInfo.NETPRECENTAGE);
				String mm = update.getNewValue(IndexFuturesInfo.MM);
				String label_name = "";
				TDStockLog.d(TAG, "netP=" + netPrecentage);
				if (mm != null && itemPos - 1 >= 0
						&& itemPos - 1 < INDEX_FUTURES_LABEL_IDS.length)
				{
					label_name = getResources().getString(
							INDEX_FUTURES_LABEL_IDS[itemPos - 1],
							Integer.parseInt(mm));
					// label_name =
					// getResources().getString(INDEX_FUTURES_LABEL_IDS[itemPos
					// - 1]);
					TDStockLog.d(TAG, "index mm = " + mm);

					TDStockLog.d("index_name", label_name + " thread :  "
							+ Thread.currentThread().getId());

				}

				// String high = update.isValueChanged(IndexFuturesInfo.HIGH) ?
				// update.getNewValue(IndexFuturesInfo.HIGH) :
				// update.getOldValue(IndexFuturesInfo.HIGH);
				// String low = update.isValueChanged(IndexFuturesInfo.LOW) ?
				// update.getNewValue(IndexFuturesInfo.LOW) :
				// update.getOldValue(IndexFuturesInfo.LOW);
				// String open = update.isValueChanged(IndexFuturesInfo.OPEN) ?
				// update.getNewValue(IndexFuturesInfo.OPEN) :
				// update.getOldValue(IndexFuturesInfo.OPEN);

				String high = update.getNewValue(IndexFuturesInfo.HIGH);
				String low = update.getNewValue(IndexFuturesInfo.LOW);
				String open = update.getNewValue(IndexFuturesInfo.OPEN);
				String vol = update.getNewValue(IndexFuturesInfo.VOL);

				TDStockLog.d("vol", " vol :  " + vol + ",item name : "
						+ itemName);
				/*
				 * TDStockLog.d(TAG, itemName== null ? "itemName = null" :
				 * "itemName=" + itemName); TDStockLog.d(TAG, last== null ?
				 * "last = null" : "last=" + last); TDStockLog.d(TAG, net== null
				 * ? "net = null" : "net=" + net); TDStockLog.d(TAG, mm== null ?
				 * "mm = null" : "mm=" + mm); TDStockLog.d(TAG, label_name==
				 * null ? "label_name = null" : "label_name=" + label_name);
				 * TDStockLog.d(TAG, high== null ? "high = null" : "high=" +
				 * high); TDStockLog.d(TAG, low== null ? "low = null" : "low=" +
				 * low); TDStockLog.d(TAG, open== null ? "open = null" : "open="
				 * + open); TDStockLog.d(TAG, "itemPos=" + itemPos);
				 * TDStockLog.d(TAG, vol== null ? "vol = null" : "vol=" + vol);
				 */

				// DT, 2011/01/14, format to 0 d.p., need to be the same as
				// iPhone app
				net = StringUtils.formatToEitherDp(net, -10.0, 10.0, 2, 0);
				if (last == null || net == null)
				{
					return;
				}

				boolean isNegative = net.indexOf("-") >= 0;
				// TextView[] holder = _index_futures_views
				// [INDEX_FUTURES_ITEMNAME_TO_POS.get(itemName)];
				/*
				 * ViewGroup[] tabContainerOnFutures = new ViewGroup[2];
				 * tabContainerOnFutures[0] =
				 * (ViewGroup)findViewById(IDS_TAB_PANEL[0]); //all items on the
				 * first tab tabContainerOnFutures[1] =
				 * (ViewGroup)findViewById(IDS_TAB_PANEL[0]); //set default
				 * tab(first tab)
				 * 
				 * switch(itemPos-1) { case 4: case 5: tabContainerOnFutures[1]
				 * = (ViewGroup)findViewById(IDS_TAB_PANEL[3]); //set tab as the
				 * third break; case 6: tabContainerOnFutures[1] =
				 * (ViewGroup)findViewById(IDS_TAB_PANEL[4]); //set tab as the
				 * fourth break; default: break; //have been set in the outside
				 * of the looper }
				 */
				for (int tab = 0; tab < 2; tab++)
				{
					TextView[] holder = _index_futures_views[tab][itemPos - 1];
					if (usingBlinkColumn)
					{
						Message exMessage;
						TextView currentView;

						currentView = holder[0];
						exMessage = /* new Message(); */UIUpdater
								.obtainMessage();
						exMessage.what = INFO_CONTENT_UPDATE;
						exMessage.obj = new DoThingsReturn(
						/*
						 * last.subSequence(0,last.indexOf('.') >= 0 ?
						 * last.indexOf('.') : last.length()),
						 */
						last == null ? ""
								: StringUtils.formatScaleInteger(Double
										.parseDouble(last)),
								currentView, 0);
						exMessage.arg1 = 1;
						UIUpdater.sendMessage(exMessage);
						ViewGroup container = (ViewGroup) currentView
								.getParent().getParent(); // two level
						((TextView) container.findViewWithTag(NAME_TAG))
								.setText(Html.fromHtml(label_name));
						// changeIndexNameTextForDelayData(container, "true");
					}
					else
					{
						final TextView currentView = holder[0];
						try
						{
							// currentView.setText(last.subSequence(0,
							// last.indexOf(".") >= 0 ? last.indexOf(".") :
							// last.length()));
							// modified by haibo, 2011-06-20, no need to do so
							// and it cause the anr.
							// //currentView.postInvalidate();
							new Thread()
							{
								public void run()
								{
									DoThingsReturn updateWrapper = new DoThingsReturn(
											/*
											 * last.subSequence(0,
											 * last.indexOf('.') >= 0 ?
											 * last.indexOf('.') :
											 * last.length()),
											 */
											last == null ? ""
													: StringUtils
															.formatScaleInteger(Double
																	.parseDouble(last)),
											currentView, 0);
									ColorRefreshTask refresh = new ColorRefreshTask(
											IndexActivity.this,
											CommonDefn.HIGHLIGHT_BACKGROUND_COLOR_INDEX,
											updateWrapper);
									_messageHandler.postDelayed(
											refresh, 50);
								}
							}.start();

							ViewGroup container = (ViewGroup) holder[0]
									.getParent().getParent(); // two level

							// ((TextView)container.findViewWithTag(NAME_TAG)).setText(label_name);
							((TextView) container
									.findViewWithTag(NAME_TAG))
									.setText(Html.fromHtml(label_name));
							// changeIndexNameTextForDelayData(container,
							// "true");
						}
						catch (Exception e)
						{
							TDStockLog.e(
									TAG,
									e.getMessage() == null ? "unknown exception happened in 1769 line ! "
											: e.getMessage());
							e.printStackTrace();
						}
					}

					{
						TextView currentView = holder[1];
						try
						{
							net = StringUtils.formatString(net,
									isNegative ? null : "+", null);
							currentView.setText(net);
							currentView
									.setTextColor(isNegative ? Color.RED
											: Color.GREEN);
							// modified by haibo, 2011-06-20, no need to do so
							// and it cause the anr.
							// currentView.postInvalidate();
						}
						catch (Exception e)
						{
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}

					{
						TextView currentView = holder[2];
						try
						{
							if (netPrecentage != null)
							{
								if (!netPrecentage.endsWith("%"))
								{
									netPrecentage = StringUtils
											.formatNumberByNetPerectage(
													netPrecentage,
													4);
								}
							}
							else
							{
								netPrecentage = CommonDefn.DEFAULT_FIELD_VALUE;
							}
							TDStockLog.d(TAG, "netPre=" + netPrecentage);
							currentView.setText(netPrecentage);
							currentView
									.setTextColor(isNegative ? Color.RED
											: Color.GREEN);
						}
						catch (Exception e)
						{
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}

					{
						try
						{
							TextView currentView = holder[3];
							currentView.setText(high.subSequence(
									0,
									high.indexOf(".") >= 0 ? high
											.indexOf(".") : high
											.length()));
							// modified by haibo, 2011-06-20, no need to do so
							// and it cause the anr.
							// currentView.postInvalidate();
						}
						catch (Exception e)
						{
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}

					{
						try
						{
							TextView currentView = holder[4];
							currentView.setText(low.subSequence(
									0,
									low.indexOf(".") >= 0 ? low
											.indexOf(".") : low
											.length()));
							// modified by haibo, 2011-06-20, no need to do so
							// and it cause the anr.
							// currentView.postInvalidate();
						}
						catch (Exception e)
						{
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}

					{
						try
						{
							TextView currentView = holder[5];
							currentView.setText(open.subSequence(
									0,
									open.indexOf(".") >= 0 ? open
											.indexOf(".") : open
											.length()));
							// modified by haibo, 2011-06-20, no need to do so
							// and it cause the anr.
							// currentView.postInvalidate();
						}
						catch (Exception e)
						{
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}

					{
						try
						{
							TextView currentView = holder[6];
							currentView.setText(vol.subSequence(
									0,
									vol.indexOf(".") >= 0 ? vol
											.indexOf(".") : vol
											.length()));
							// modified by haibo, 2011-06-20, no need to do so
							// and it cause the anr.
							// currentView.postInvalidate();
						}
						catch (Exception e)
						{
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}

				} // end the loop
			}
		};

		new Thread()
		{
			public void run()
			{
				_messageHandler.post(myUpdateResults);
			}
		}.start();
	}

	private class LightStreamerHandlerOnIndexFutures implements
		LightStreamerHandlerInterface
	{
		private boolean	isFirstTimeArrival;

		public void onUpdate(final int itemPos, final String itemName,
				final UpdateInfo update)
		{
			if (_isInBackground)
			{
				Thread.yield();
				return;
			}
			try
			{
				if (!isFirstTimeArrival)
				{
					isFirstTimeArrival = true;
					TDStockLog.d(TAG,
							"have got the data in  Index futures!");
				}
				onUpdateIndexFutures(itemPos, itemName, update);
			}
			catch (Exception e)
			{
				// TODO Auto-generated catch block
				TDStockLog.d(
						TAG,
						"insert result:" + e.getMessage() == null ? "unknown exception!"
								: e.getMessage());
			}
		}
	}

	private void onUpdateWorldFutures(final int itemPos,
			final String itemName, final UpdateInfo update)
	{
		final Runnable myUpdateResults = new Runnable()
		{
			public void run()
			{
				// final String last =
				// update.isValueChanged(WorldFuturesInfo.LAST) ?
				// update.getNewValue(WorldFuturesInfo.LAST) :
				// update.getOldValue(WorldFuturesInfo.LAST);
				// String net = update.isValueChanged(WorldFuturesInfo.NET) ?
				// update.getNewValue(WorldFuturesInfo.NET) :
				// update.getOldValue(WorldFuturesInfo.NET);
				// String mm = update.isValueChanged(WorldFuturesInfo.MM) ?
				// update.getNewValue(WorldFuturesInfo.MM) :
				// update.getOldValue(WorldFuturesInfo.MM);

				final String last = update
						.getNewValue(WorldFuturesInfo.LAST);
				String net = update.getNewValue(WorldFuturesInfo.NET);
				String mm = update.getNewValue(WorldFuturesInfo.MM);
				/*
				 * String label_name = ""; String label_name2 = "";
				 * 
				 * if (mm != null && itemPos - 1 >= 0 && itemPos - 1 <
				 * INDEX_FUTURES_LABEL_IDS.length) { label_name =
				 * getResources().getString(INDEX_FUTURES_LABEL_IDS[itemPos -
				 * 1], Integer.parseInt(mm)); label_name2 =
				 * getResources().getString(INDEX_FUTURES_LABEL_IDS_2[itemPos -
				 * 1], Integer.parseInt(mm)); TDStockLog.d(TAG, "index mm = "
				 * +mm ); TDStockLog.d("index_name", label_name );
				 * 
				 * }
				 */

				// String high = update.isValueChanged(WorldFuturesInfo.HIGH) ?
				// update.getNewValue(WorldFuturesInfo.HIGH) :
				// update.getOldValue(WorldFuturesInfo.HIGH);
				// String low = update.isValueChanged(WorldFuturesInfo.LOW) ?
				// update.getNewValue(WorldFuturesInfo.LOW) :
				// update.getOldValue(WorldFuturesInfo.LOW);
				// String open = update.isValueChanged(WorldFuturesInfo.OPEN) ?
				// update.getNewValue(WorldFuturesInfo.OPEN) :
				// update.getOldValue(WorldFuturesInfo.OPEN);
				String high = update.getNewValue(WorldFuturesInfo.HIGH);
				String low = update.getNewValue(WorldFuturesInfo.LOW);
				String open = update.getNewValue(WorldFuturesInfo.OPEN);

				// String vol = update.getNewValue(WorldFuturesInfo.Vol);
				/*
				 * TDStockLog.d(TAG, itemName== null ? "itemName = null" :
				 * "itemName=" + itemName); TDStockLog.d(TAG, last== null ?
				 * "last = null" : "last=" + last); TDStockLog.d(TAG, net== null
				 * ? "net = null" : "net=" + net); TDStockLog.d(TAG, mm== null ?
				 * "mm = null" : "mm=" + mm); TDStockLog.d(TAG, label_name==
				 * null ? "label_name = null" : "label_name=" + label_name);
				 * TDStockLog.d(TAG, high== null ? "high = null" : "high=" +
				 * high); TDStockLog.d(TAG, low== null ? "low = null" : "low=" +
				 * low); TDStockLog.d(TAG, open== null ? "open = null" : "open="
				 * + open); TDStockLog.d(TAG, "itemPos=" + itemPos);
				 */
				// TDStockLog.d(TAG, vol== null ? "vol = null" : "vol=" + vol);

				// DT, 2011/01/14, format to 0 d.p., need to be the same as
				// iPhone app
				net = StringUtils.formatToEitherDp(net, -10.0, 10.0, 2, 0);

				if (last == null || net == null)
				{
					return;
				}

				/*
				 * String net_percentage = "0"; if
				 * (Math.abs(Double.parseDouble(last)) >
				 * CommonDefn.APPROACH_ZERO) { // DT, 2011/01/14, format to 2
				 * d.p., need to be the same as iPhone app //net_percentage =
				 * _formater.format( Double.parseDouble(net) /
				 * Double.parseDouble(last) * 100.00d) + "%"; net_percentage =
				 * StringUtils.formatToDp((Double .parseDouble(net) /
				 * Double.parseDouble(last) * 100.00d), 2) + "%"; }
				 */
				boolean isNegative = net.indexOf("-") >= 0;
				// TextView[] holder = _index_futures_views
				// [INDEX_FUTURES_ITEMNAME_TO_POS.get(itemName)];

				/*
				 * ViewGroup[] tabContainerOnFutures = new ViewGroup[2];
				 * tabContainerOnFutures[0] =
				 * (ViewGroup)findViewById(IDS_TAB_PANEL[0]); //all items on the
				 * first tab tabContainerOnFutures[1] =
				 * (ViewGroup)findViewById(IDS_TAB_PANEL[0]); //set default
				 * tab(first tab)
				 * 
				 * switch(itemPos-1) { case 4: case 5: tabContainerOnFutures[1]
				 * = (ViewGroup)findViewById(IDS_TAB_PANEL[3]); //set tab as the
				 * third break; case 6: tabContainerOnFutures[1] =
				 * (ViewGroup)findViewById(IDS_TAB_PANEL[4]); //set tab as the
				 * fourth break; default: break; //have been set in the outside
				 * of the looper }
				 */

				for (int tab = 0; tab < 2; tab++)
				{
					TextView[] holder = _index_futures_views[tab][itemPos - 1];
					if (usingBlinkColumn)
					{
						Message exMessage;
						TextView currentView;

						currentView = holder[0];
						exMessage = /* new Message(); */UIUpdater
								.obtainMessage();
						exMessage.what = INFO_CONTENT_UPDATE;
						exMessage.obj = new DoThingsReturn(
						/*
						 * last.subSequence(0,last.indexOf('.') >= 0 ?
						 * last.indexOf('.') : last.length()),
						 */
						last == null ? ""
								: StringUtils.formatScaleInteger(Double
										.parseDouble(last)),
								currentView, 0);
						exMessage.arg1 = 1;
						UIUpdater.sendMessage(exMessage);

						ViewGroup container = (ViewGroup) currentView
								.getParent().getParent(); // two level

						TextView index_name = ((TextView) container
								.findViewWithTag(NAME_TAG));
						index_name.setText(index_name
								.getText()
								.toString()
								.replace("--",
										String.valueOf(Integer
												.parseInt(mm))));

						/*
						 * if
						 * (((ITDLApplication)getApplicationContext()).getDataMode
						 * () == DataMode.Delay) { ((TextView)
						 * container.findViewWithTag
						 * (NAME_TAG)).setText(Html.fromHtml( label_name ));
						 * ((TextView)
						 * container.findViewWithTag(NAME_TAG)).setTextColor
						 * (Color.WHITE); } else {
						 * if(((ViewGroup)container.getParent
						 * ().getParent()).getId() == R.id.index_occident_tab ||
						 * (
						 * (ViewGroup)container.getParent().getParent()).getId()
						 * ==R.id.index_asia_tab) { ((TextView)
						 * container.findViewWithTag
						 * (NAME_TAG)).setText(Html.fromHtml( label_name )); }
						 * else { ((TextView)
						 * container.findViewWithTag(NAME_TAG)
						 * ).setText(Html.fromHtml( label_name2 )); }
						 * ((TextView)
						 * container.findViewWithTag(NAME_TAG)).setTextColor
						 * (Color.YELLOW); }
						 */

						// changeIndexNameTextForDelayData(container);
					}
					else
					{
						final TextView currentView = holder[0];
						try
						{
							// currentView.setText(last.subSequence(0,
							// last.indexOf(".") >= 0 ? last.indexOf(".") :
							// last.length()));
							// currentView.postInvalidate();
							new Thread()
							{
								public void run()
								{

									DoThingsReturn updateWrapper = new DoThingsReturn(
											/*
											 * last.subSequence(0,
											 * last.indexOf('.') >= 0 ?
											 * last.indexOf('.') :
											 * last.length()),
											 */
											last == null ? ""
													: StringUtils
															.formatScaleInteger(Double
																	.parseDouble(last)),
											currentView, 0);
									ColorRefreshTask refresh = new ColorRefreshTask(
											IndexActivity.this,
											CommonDefn.HIGHLIGHT_BACKGROUND_COLOR_INDEX,
											updateWrapper);
									_messageHandler.postDelayed(
											refresh, 50);
								}
							}.start();

							ViewGroup container = (ViewGroup) holder[0]
									.getParent().getParent(); // two level

							TextView index_name = ((TextView) container
									.findViewWithTag(NAME_TAG));
							index_name.setText(index_name
									.getText()
									.toString()
									.replace("--",
											String.valueOf(Integer
													.parseInt(mm))));

							/*
							 * if (((ITDLApplication)getApplicationContext()).
							 * getDataMode() == DataMode.Delay) { ((TextView)
							 * container
							 * .findViewWithTag(NAME_TAG)).setText(Html.
							 * fromHtml( label_name )); ((TextView)
							 * container.findViewWithTag
							 * (NAME_TAG)).setTextColor(Color.WHITE); } else {
							 * if
							 * (((ViewGroup)container.getParent().getParent()).
							 * getId() == R.id.index_occident_tab ||
							 * ((ViewGroup)
							 * container.getParent().getParent()).getId()
							 * ==R.id.index_asia_tab) { ((TextView)
							 * container.findViewWithTag
							 * (NAME_TAG)).setText(Html.fromHtml( label_name ));
							 * } else { ((TextView)
							 * container.findViewWithTag(NAME_TAG
							 * )).setText(Html.fromHtml( label_name2 )); }
							 * ((TextView)
							 * container.findViewWithTag(NAME_TAG)).setTextColor
							 * (Color.YELLOW); }
							 */

							// changeIndexNameTextForDelayData(container);
						}
						catch (Exception e)
						{
							TDStockLog.e(
									TAG,
									e.getMessage() == null ? "unkown exception in  line 2072 "
											: e.getMessage());
							e.printStackTrace();
						}
					}

					{
						TextView currentView = holder[1];
						try
						{
							net = StringUtils.formatString(net,
									isNegative ? null : "+", null);
							currentView.setText(net);
							currentView
									.setTextColor(isNegative ? Color.RED
											: Color.GREEN);
							// modified by haibo, 2011-06-20, no need to do so
							// and it cause the anr.
							// currentView.postInvalidate();
						}
						catch (Exception e)
						{
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}

					{
						TextView currentView = holder[2];
						currentView.setText("");
						/*
						 * try { net_percentage = StringUtils.formatString(
						 * net_percentage, isNegative ? null : "+", null);
						 * currentView.setText(net_percentage); currentView
						 * .setTextColor(isNegative ? Color.RED : Color.GREEN);
						 * // modified by haibo, 2011-06-20, no need to do so
						 * and it cause the anr. currentView.postInvalidate(); }
						 * catch (Exception e) { // TODO Auto-generated catch
						 * block e.printStackTrace(); }
						 */
					}

					{
						try
						{
							TextView currentView = holder[3];
							currentView.setText(high.subSequence(
									0,
									high.indexOf(".") >= 0 ? high
											.indexOf(".") : high
											.length()));
							// modified by haibo, 2011-06-20, no need to do so
							// and it cause the anr.
							// currentView.postInvalidate();
						}
						catch (Exception e)
						{
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}

					{
						try
						{
							TextView currentView = holder[4];
							currentView.setText(low.subSequence(
									0,
									low.indexOf(".") >= 0 ? low
											.indexOf(".") : low
											.length()));
							// modified by haibo, 2011-06-20, no need to do so
							// and it cause the anr.
							// currentView.postInvalidate();
						}
						catch (Exception e)
						{
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}

					{
						try
						{
							TextView currentView = holder[5];
							currentView.setText(open.subSequence(
									0,
									open.indexOf(".") >= 0 ? open
											.indexOf(".") : open
											.length()));
							// modified by haibo, 2011-06-20, no need to do so
							// and it cause the anr.
							// currentView.postInvalidate();
						}
						catch (Exception e)
						{
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}
					// {
					// // by ouyangzhihui 2011-10-14
					// TextView currentView = holder[6];
					// currentView.setText("");
					// }
				}
			}
		};

		new Thread()
		{
			public void run()
			{
				if (_messageHandler != null)
					_messageHandler.post(myUpdateResults);
			}
		}.start();
	}

	private class LightStreamerHandlerOnWorldFutures implements
		LightStreamerHandlerInterface
	{
		public void onUpdate(final int itemPos, final String itemName,
				final UpdateInfo update)
		{
			if (_isInBackground)
			{
				return;
			}
			try
			{
				onUpdateWorldFutures(itemPos + 4, itemName, update);
			}
			catch (Exception e)
			{
				// TODO Auto-generated catch block
				TDStockLog.d(
						TAG,
						"insert result:" + e.getMessage() == null ? "unknown exception!"
								: e.getMessage());
			}
		}
	}

	private void initTabButtons()
	{

		// final ViewGroup tab = (ViewGroup)findViewById(R.id.mock_tab);
		for (int index = 0, count = TAB_BTN_IDS.length; index < count; index++)
		{
			_tabBtns[index] = (Button) findViewById(TAB_BTN_IDS[index]);
		}
		for (int index = 0, count = /* tab.getChildCount() */TAB_BTN_IDS.length; index < count; index++)
		{
			final Button btn = /* (Button)tab.getChildAt(index); */_tabBtns[index];
			final int currentIndex = index;
			final int btnCount = count;
			btn.setWidth((_display.getWidth() - count - 1) / count);
			btn.setOnClickListener(new OnClickListener()
			{
				@Override
				public void onClick(View v)
				{
					final Runnable myUpdateResults = new Runnable()
					{
						public void run()
						{

							if (((ITDLApplication) getApplicationContext())
									.getDataMode() != CommonDefn.DataMode.Delay)
							{
								if (currentIndex == 3
										|| currentIndex == 4)
								{
									_top_bar_title
											.setText(getResources()
													.getString(
															R.string.index_delay));
									// modified by haibo, 2011-06-20, no need to
									// do so and it cause the anr.
									// _top_bar_title.postInvalidate();
								}
								else
								{
									_top_bar_title
											.setText(getResources()
													.getString(
															R.string.index));
									// modified by haibo, 2011-06-20, no need to
									// do so and it cause the anr.
									// _top_bar_title.postInvalidate();
								}

							}
							else
							{
								resetTitle();
							}

							for (int item = 0, itemCount = TAB_BTN_IDS.length; item < itemCount; item++)
							{
								Button tmpBtn = _tabBtns[item];
								if (item != 0 && item != itemCount - 1)
								{
									tmpBtn.setBackgroundDrawable(null);
									tmpBtn.setBackgroundColor(0xfff1f1f1);
								}
								else
								{
									tmpBtn.setBackgroundDrawable(null);
									tmpBtn.setBackgroundResource(item == 0 ? R.drawable.rect_left_grey
											: R.drawable.rect_right_grey);
								}
								tmpBtn.setTextColor(R.color.grey);
								// modified by haibo, 2011-06-20, no need to do
								// so and it cause the anr.
								// tmpBtn.postInvalidate();

								ViewGroup tmpView = (ViewGroup) findViewById(IDS_TAB_PANEL[item]);
								tmpView.setVisibility(View.GONE);
								// modified by haibo, 2011-06-20, no need to do
								// so and it cause the anr.
								// tmpView.postInvalidate();
							}
							// btn.setBackgroundColor(0xff97e4e8);
							btn.setBackgroundResource(currentIndex == 0 ? R.drawable.gradient_rect_left
									: (currentIndex == btnCount - 1 ? R.drawable.gradient_rect_right
											: R.drawable.gradient_rect));
							btn.setTextColor(Color.WHITE);
							// modified by haibo, 2011-06-20, no need to do so
							// and it cause the anr. btn.postInvalidate();

							ViewGroup tmpView = (ViewGroup) findViewById(IDS_TAB_PANEL[currentIndex]);
							tmpView.setVisibility(View.VISIBLE);
							tmpView.postInvalidate();

							/*
							 * if (_isShowingStreamerTimeoutLabel) { TDStockLog
							 * .d(TAG,
							 * "ready to deal with streamer timeout label!");
							 * performClickStreamerTimeoutLabel(); if
							 * (_streamerTimeoutHandler != null) {
							 * _streamerTimeoutHandler .startCounter( 0,0); } }
							 * else { TDStockLog .d(TAG,
							 * "there 's no any streamerTimeout label!!");
							 * reConnectLightstreamerIfDisconnect();
							 * 
							 * }
							 */

							if (_isShowingStreamerTimeoutLabel)
							{
								performClickStreamerTimeoutLabel();
							}

						}
					};
					new Thread()
					{
						public void run()
						{
							if (_messageHandler != null)
								_messageHandler.post(myUpdateResults);
						}
					}.start();

				}
			});
		}

	}

	/*
	 * private void setYellowColorForTab4AndTab5(){ int[] groupIds = {
	 * R.id.index_jp, R.id.index_jp_later_month, R.id.index_jp_more_later_month,
	 * R.id.index_kospi, R.id.index_sti, R.id.index_tai, R.id.index_aord,
	 * R.id.index_nzx, R.id.index_sen,R.id.index_set,
	 * R.id.index_jkt,R.id.index_kls,R.id.index_psi,
	 * 
	 * 
	 * 
	 * R.id.index_dj, R.id.index_dj_later_month,R.id.index_nasd,
	 * R.id.index_sp,R.id.index_ftse, R.id.index_cac,R.id.index_dax
	 * 
	 * };
	 * 
	 * 
	 * for(int index = 0; index < groupIds.length; index++) { ViewGroup
	 * container = (ViewGroup)findViewById(groupIds[index]); if(container !=
	 * null) { TextView index_name =
	 * (TextView)container.findViewWithTag(NAME_TAG); if(index_name != null) {
	 * if(index_name.getText().toString().contains("(延遲)")) {
	 * index_name.setText(index_name.getText().toString().replace("\\(延遲\\)",
	 * "")); index_name.setTextColor(Color.YELLOW); }
	 * 
	 * 
	 * }
	 * 
	 * }
	 * 
	 * 
	 * }
	 * 
	 * 
	 * 
	 * 
	 * 
	 * }
	 */

	private void initIndexViews()
	{
		/*------------------------*/
		int index_futures_hsi_later_label = R.string.index_futures_hsi_later_label;
		int index_hscei_later_label = R.string.index_hscei_later_label;
		// account login svcPlan2=0
		if (!((ITDLApplication) getApplicationContext())
				.getIsRealtimeFutures()
				&& ((ITDLApplication) getApplicationContext())
						.getModeType() == CommonDefn.ModeType.ACCOUNTLOGIN)
		{
			index_futures_hsi_later_label = R.string.index_futures_hsi_morelater_label;
			index_hscei_later_label = R.string.index_hscei_morelater_label;
		}
		INDEX_FUTURES_LABEL_IDS = new int[] { index_futures_hsi_later_label,
				index_futures_hsi_later_label, index_hscei_later_label,
				index_hscei_later_label, R.string.index_n225_later_label,
				R.string.index_n225_later_label,
				R.string.index_dji_later_label };
		INDEX_FUTURES_LABEL_IDS_2 = new int[] {
				index_futures_hsi_later_label,
				index_futures_hsi_later_label, index_hscei_later_label,
				index_hscei_later_label,
				R.string.index_n225_morelater_label,
				R.string.index_n225_morelater_label,
				R.string.index_dji_morelater_label };
		/*------------------------*/

		ViewGroup tab1Container = (ViewGroup) findViewById(IDS_TAB_PANEL[0]);
		ViewGroup tab2Container = (ViewGroup) findViewById(IDS_TAB_PANEL[1]);
		ViewGroup[] tabContainer = { tab1Container, tab2Container };

		for (int index = 0; index < 2; index++)
		{

			ViewGroup index_container = (ViewGroup) tabContainer[index]
					.findViewById(R.id.index_phsi);
			if (index_container != null)
			{
				// ((TextView)index_container.findViewWithTag(NAME_TAG)).setText(R.string.index_hsi_label);
				String nameRes = getResources().getString(
						R.string.index_hsi_label);
				((TextView) index_container.findViewWithTag(NAME_TAG))
						.setText(Html.fromHtml(nameRes));
				changeIndexNameTextForDelayData(index_container);

				((TextView) index_container
						.findViewWithTag(REPLACEMENT_TAG))
						.setText(R.string.index_turnover);
				Button addToMonitor = (Button) index_container
						.findViewWithTag(NAME_ADDTO_MONITOR_TAG);
				ViewGroup addToMonitor_container = (ViewGroup) index_container
						.findViewWithTag("addto_monitor_tag_container");
				if (addToMonitor != null)
				{
					AddIndexClickHandler handler = new AddIndexClickHandler(
							this);
					handler.setAdapter(IndexInfo.ADAPTER);
					handler.setItem(INDEX_NAME_HSI);
					handler.setFields(
							getResources().getString(
									R.string.index_hsi_label),
							IndexInfo.INDEXLAST, IndexInfo.INDEXNET, "");
					addToMonitor.setOnClickListener(handler);
					addToMonitor_container.setOnClickListener(handler);
				}

				ImageView imageView = (ImageView) index_container
						.findViewWithTag(TAG_CHART);
				if (imageView != null)
				{
					imageView.setVisibility(isShouldShowImg(INDEX_NAME_HSI) ? View.VISIBLE
							: View.GONE);
					imageView.setClickable(true);
					imageView.setFocusable(true);
					imageView.setTag(CHART_IMG_TAG_FOR_KEY, INDEX_NAME_HSI);

					/*
					 * imageView.setOnClickListener(new ForwardToChart(
					 * INDEX_NAME_HSI, getResources().getString(
					 * R.string.index_hsi_label), index_container));
					 */

					imageView.setTag(
							CHART_IMG_TAG_FOR_CLICK,
							new ForwardToChart(
									INDEX_NAME_HSI,
									getResources()
											.getString(
													R.string.index_hsi_label),
									index_container)); // modified by haibo,
													// 2011-07-28, avoid to
													// click the image to
													// enter chart

					// add description too see chart
					rotateToseeChart(index_container);
					// add description too see chart

				}

				for (int item = 0, count = TAGS.length; item < count; item++)
				{
					// each index has a tag
					_index_hsi_views[index][item] = (TextView) index_container
							.findViewWithTag(TAGS[item]);
				}
			}

		}

		for (int index = 0; index < 2; index++)
		{

			ViewGroup hscei_container = (ViewGroup) tabContainer[index]
					.findViewById(R.id.index_hscei);
			if (hscei_container != null)
			{
				// ((TextView)hscei_container.findViewWithTag(NAME_TAG)).setText(R.string.index_hscei_label);
				String nameRes = getResources().getString(
						R.string.index_hscei_label);
				((TextView) hscei_container.findViewWithTag(NAME_TAG))
						.setText(nameRes);

				changeIndexNameTextForDelayData(hscei_container);
				Button addToMonitor = (Button) hscei_container
						.findViewWithTag(NAME_ADDTO_MONITOR_TAG);
				ViewGroup addToMonitor_container = (ViewGroup) hscei_container
						.findViewWithTag("addto_monitor_tag_container");
				if (addToMonitor != null)
				{
					AddIndexClickHandler handler = new AddIndexClickHandler(
							this);
					handler.setAdapter(IndexInfo.ADAPTER);
					handler.setItem(INDEX_NAME_HSCEI);
					handler.setFields(
							getResources().getString(
									R.string.index_hscei_label),
							IndexInfo.INDEXLAST, IndexInfo.INDEXNET, "");
					addToMonitor.setOnClickListener(handler);
					addToMonitor_container.setOnClickListener(handler);
				}

				ImageView imageView = (ImageView) hscei_container
						.findViewWithTag(TAG_CHART);
				if (imageView != null)
				{
					imageView.setVisibility(isShouldShowImg(INDEX_NAME_HSCEI) ? View.VISIBLE
							: View.GONE);
					imageView.setClickable(true);
					imageView.setFocusable(true);
					imageView.setTag(CHART_IMG_TAG_FOR_KEY,
							INDEX_NAME_HSCEI);

					// --------modified by haibo, 2011-07-28, avoid to click the
					// image to enter chart-----------
					/*
					 * imageView.setOnClickListener(new ForwardToChart(
					 * INDEX_NAME_HSCEI, getResources().getString(
					 * R.string.index_hscei_label), hscei_container));
					 */

					imageView.setTag(
							CHART_IMG_TAG_FOR_CLICK,
							new ForwardToChart(
									INDEX_NAME_HSCEI,
									getResources()
											.getString(
													R.string.index_hscei_label),
									hscei_container));

					// --------modified by haibo, 2011-07-28, avoid to click the
					// image to enter chart-----------

					// add description too see chart
					rotateToseeChart(hscei_container);
					// add description too see chart

				}
				// each index has a tag
				for (int item = 0, count = TAGS.length; item < count; item++)
				{
					_index_hscei_views[index][item] = (TextView) hscei_container
							.findViewWithTag(TAGS[item]);
				}
			}

		}

		int[] ids_futures = { R.id.index_phsi_current_month,
				R.id.index_phsi_next_month, R.id.index_hscei_current_month,
				R.id.index_hscei_next_month, R.id.index_jp_later_month,
				R.id.index_jp_more_later_month, R.id.index_dj_later_month };

		ViewGroup[] tabContainerOnFutures = new ViewGroup[2];
		tabContainerOnFutures[0] = (ViewGroup) findViewById(IDS_TAB_PANEL[0]); // all
																	// items
																	// on
																	// the
																	// first
																	// tab
		tabContainerOnFutures[1] = (ViewGroup) findViewById(IDS_TAB_PANEL[1]); // set
																	// default
																	// tab(
																	// the
																	// secondary
																	// tab)
		for (int index = 0, count = ids_futures.length; index < count; index++)
		{
			int index_futures_label_ids = INDEX_FUTURES_LABEL_IDS[index];
			switch (index)
			{
				case 4:
				case 5:
					tabContainerOnFutures[1] = (ViewGroup) findViewById(IDS_TAB_PANEL[3]); // set
																				// tab
																				// as
																				// the
																				// third
					break;
				case 6:
					tabContainerOnFutures[1] = (ViewGroup) findViewById(IDS_TAB_PANEL[4]); // set
																				// tab
																				// as
																				// the
																				// fourth
					break;
				default:
					break; // have been set in the outside of the looper
			}

			for (int tab = 0; tab < 2; tab++)
			{

				ViewGroup container = (ViewGroup) tabContainerOnFutures[tab]
						.findViewById(ids_futures[index]);
				/*------------- by ouyangzhihui 2011-08-24 ------------*/
				if (((ITDLApplication) getApplicationContext())
						.getDataMode() == DataMode.Delay)
				{
					index_futures_label_ids = INDEX_FUTURES_LABEL_IDS[index];
				}
				else
				{
					if (tab == 0)
					{
						index_futures_label_ids = INDEX_FUTURES_LABEL_IDS_2[index];
					}
					else
					{
						index_futures_label_ids = INDEX_FUTURES_LABEL_IDS[index];
					}
				}
				String nameRes = getResources().getString(
						index_futures_label_ids, "--");
				((TextView) container.findViewWithTag(NAME_TAG))
						.setText(Html.fromHtml(nameRes));

				changeIndexNameTextForDelayData(container);
				/*------------- by ouyangzhihui 2011-08-24 -----------*/

				if (tab == 0 && index > 3) // 预设：日經指數上月期貨,日經指數下月期貨,道瓊斯本月期貨
				{
					container.findViewWithTag(REPLACEMENT_TAG)
							.setVisibility(View.GONE);
				}
				else if (tab > 0 && index > 3) // tab 4,5:
											// 日經指數上月期貨,日經指數下月期貨,道瓊斯本月期貨
				{
					((TextView) container.findViewWithTag(REPLACEMENT_TAG))
							.setText(R.string.index_prev);
				}
				else
				{
					((TextView) container.findViewWithTag(REPLACEMENT_TAG))
							.setText(R.string.index_sharetraded);
				}

				Button addToMonitor = (Button) container
						.findViewWithTag(NAME_ADDTO_MONITOR_TAG);
				ViewGroup addToMonitor_container = (ViewGroup) container
						.findViewWithTag("addto_monitor_tag_container");
				if (addToMonitor != null)
				{
					AddIndexClickHandler handler = new AddIndexClickHandler(
							this);
					handler.setAdapter(index <= 3 ? IndexFuturesInfo.ADAPTER
							: WorldFuturesInfo.ADAPTER);
					handler.setItem(index <= 3 ? INDEX_FUTURES_ITEMS[index]
							: WORLD_FUTURES_ITEMS[index - 4]);
					handler.setFields("", "", "", "");
					addToMonitor.setOnClickListener(handler);
					addToMonitor_container.setOnClickListener(handler);
				}
				ImageView imageView = (ImageView) container
						.findViewWithTag(TAG_CHART);
				if (imageView != null)
				{
					imageView.setVisibility(isShouldShowImg(index <= 3 ? INDEX_FUTURES_ITEMS[index]
							: WORLD_FUTURES_ITEMS[index - 4]) ? View.VISIBLE
							: View.GONE);
					imageView.setClickable(true);
					imageView.setFocusable(true);
					imageView.setTag(CHART_IMG_TAG_FOR_KEY,
							index <= 3 ? INDEX_FUTURES_ITEMS[index]
									: WORLD_FUTURES_ITEMS[index - 4]);

					// --------modified by haibo, 2011-07-28, avoid to click the
					// image to enter chart-----------

					/*
					 * imageView.setOnClickListener(new ForwardToChart( index <=
					 * 3 ? INDEX_FUTURES_ITEMS[index] :
					 * WORLD_FUTURES_ITEMS[index - 4], null, container));
					 */

					imageView.setTag(
							CHART_IMG_TAG_FOR_CLICK,
							new ForwardToChart(
									index <= 3 ? INDEX_FUTURES_ITEMS[index]
											: WORLD_FUTURES_ITEMS[index - 4],
									null, container));

					// --------modified by haibo, 2011-07-28, avoid to click the
					// image to enter chart-----------

					// add description too see chart
					rotateToseeChart(container);
					// add description too see chart

				}

				TextView[] holder = _index_futures_views[tab][index];
				for (int item = 0, itemCount = TAGS.length; item < itemCount; item++)
				{
					// each index has a tag
					holder[item] = (TextView) container
							.findViewWithTag(TAGS[item]);
				}
				if (tab == 0 && index > 3)
				{
					holder[6].setVisibility(View.GONE);
				}
			}

		}
		/*-----上証（SSEI）----*/
		for (int index = 0, count = WORLD_INDEX_DELAYREALTIME_IDS.length; index < count; index++)
		{
			ViewGroup container = (ViewGroup) findViewById(WORLD_INDEX_DELAYREALTIME_IDS[index]);
			TextView[] holder = _world_index_delay_realtime_views[index];

			// ((TextView)container.findViewWithTag(NAME_TAG)).setText(WORLD_INDEX_LABEL_IDS[index]);

			String nameRes = getResources().getString(
					WORLD_INDEX_DELAYREALTIME_LABEL_IDS[index]);
			((TextView) container.findViewWithTag(NAME_TAG)).setText(Html
					.fromHtml(nameRes));

			changeIndexNameTextForDelayData(container);

			Button addToMonitor = (Button) container
					.findViewWithTag(NAME_ADDTO_MONITOR_TAG);
			ViewGroup addToMonitor_container = (ViewGroup) container
					.findViewWithTag("addto_monitor_tag_container");
			if (addToMonitor != null)
			{
				AddIndexClickHandler handler = new AddIndexClickHandler(
						this);
				handler.setAdapter(WorldIndexInfo.ADAPTER
						+ WorldIndexDelayInfo.ADAPTER); // "上証SSEI"
				handler.setItem(WORLD_INDEX_ITEMS_DELAY_AND_REALTIME[index]);
				handler.setFields(
						getResources()
								.getString(
										WORLD_INDEX_DELAYREALTIME_LABEL_IDS[index]),
						WorldIndexInfo.LAST, WorldIndexInfo.NET,
						WorldIndexInfo.NETPERCENTAGE);
				addToMonitor.setOnClickListener(handler);
				addToMonitor_container.setOnClickListener(handler);
			}

			ImageView imageView = (ImageView) container
					.findViewWithTag(TAG_CHART);
			if (imageView != null)
			{
				imageView.setVisibility(isShouldShowImg(WORLD_INDEX_ITEMS_DELAY_AND_REALTIME[index]) ? View.VISIBLE
						: View.GONE);
				imageView.setClickable(true);
				imageView.setFocusable(true);
				imageView.setTag(CHART_IMG_TAG_FOR_KEY,
						WORLD_INDEX_ITEMS_DELAY_AND_REALTIME[index]);

				// --------modified by haibo, 2011-07-28, avoid to click the
				// image to enter chart-----------
				/*
				 * imageView.setOnClickListener(new ForwardToChart(
				 * WORLD_INDEX_ITEMS[index], getResources().getString(
				 * WORLD_INDEX_LABEL_IDS[index]), container));
				 */

				imageView.setTag(
						CHART_IMG_TAG_FOR_CLICK,
						new ForwardToChart(
								WORLD_INDEX_ITEMS_DELAY_AND_REALTIME[index],
								getResources()
										.getString(
												WORLD_INDEX_DELAYREALTIME_LABEL_IDS[index]),
								container));

				// --------modified by haibo, 2011-07-28, avoid to click the
				// image to enter chart-----------

				// add description too see chart
				rotateToseeChart(container);
				// add description too see chart

			}

			for (int item = 0, itemCount = holder.length; item < itemCount; item++)
			{
				// each index has a tag
				holder[item] = (TextView) container
						.findViewWithTag(TAGS[item]);
			}

		}
		/*-----------------end--------*/

		for (int index = 0, count = WORLD_INDEX_IDS.length; index < count; index++)
		{
			ViewGroup container = (ViewGroup) findViewById(WORLD_INDEX_IDS[index]);
			TextView[] holder = _world_index_views[index];

			// ((TextView)container.findViewWithTag(NAME_TAG)).setText(WORLD_INDEX_LABEL_IDS[index]);

			String nameRes = getResources().getString(
					WORLD_INDEX_LABEL_IDS[index]);
			((TextView) container.findViewWithTag(NAME_TAG)).setText(Html
					.fromHtml(nameRes));

			changeIndexNameTextForDelayData(container);

			Button addToMonitor = (Button) container
					.findViewWithTag(NAME_ADDTO_MONITOR_TAG);
			ViewGroup addToMonitor_container = (ViewGroup) container
					.findViewWithTag("addto_monitor_tag_container");
			if (addToMonitor != null)
			{
				AddIndexClickHandler handler = new AddIndexClickHandler(
						this);
				handler.setAdapter(WorldIndexInfo.ADAPTER);
				handler.setItem(WORLD_INDEX_ITEMS[index]);
				handler.setFields(
						getResources().getString(
								WORLD_INDEX_LABEL_IDS[index]),
						WorldIndexInfo.LAST, WorldIndexInfo.NET,
						WorldIndexInfo.NETPERCENTAGE);
				addToMonitor.setOnClickListener(handler);
				addToMonitor_container.setOnClickListener(handler);
			}

			ImageView imageView = (ImageView) container
					.findViewWithTag(TAG_CHART);
			if (imageView != null)
			{
				imageView.setVisibility(isShouldShowImg(WORLD_INDEX_ITEMS[index]) ? View.VISIBLE
						: View.GONE);
				imageView.setClickable(true);
				imageView.setFocusable(true);
				imageView.setTag(CHART_IMG_TAG_FOR_KEY,
						WORLD_INDEX_ITEMS[index]);

				// --------modified by haibo, 2011-07-28, avoid to click the
				// image to enter chart-----------
				/*
				 * imageView.setOnClickListener(new ForwardToChart(
				 * WORLD_INDEX_ITEMS[index], getResources().getString(
				 * WORLD_INDEX_LABEL_IDS[index]), container));
				 */

				imageView.setTag(
						CHART_IMG_TAG_FOR_CLICK,
						new ForwardToChart(
								WORLD_INDEX_ITEMS[index],
								getResources().getString(
										WORLD_INDEX_LABEL_IDS[index]),
								container));

				// --------modified by haibo, 2011-07-28, avoid to click the
				// image to enter chart-----------

				// add description too see chart
				rotateToseeChart(container);
				// add description too see chart

			}

			for (int item = 0, itemCount = holder.length; item < itemCount; item++)
			{
				// each index has a tag
				holder[item] = (TextView) container
						.findViewWithTag(TAGS[item]);
			}

		}

		for (int index = 0, count = INDEX_CATEGORY.length; index < count; index++)
		{
			ViewGroup container = (ViewGroup) findViewById(INDEX_CATEGORY[index]);
			TextView[] holder = _index_category[index];
			String nameRes = getResources().getString(
					INDEX_CATEGORY_LABEL[index]);
			// ((TextView)container.findViewWithTag(NAME_TAG)).setText(INDEX_CATEGORY_LABEL[index]);
			((TextView) container.findViewWithTag(NAME_TAG)).setText(Html
					.fromHtml(nameRes));

			changeIndexNameTextForDelayData(container);
			Button addToMonitor = (Button) container
					.findViewWithTag(NAME_ADDTO_MONITOR_TAG);
			ViewGroup addToMonitor_container = (ViewGroup) container
					.findViewWithTag("addto_monitor_tag_container");
			if (addToMonitor != null)
			{
				AddIndexClickHandler handler = new AddIndexClickHandler(
						this);
				handler.setAdapter(IndexInfo.ADAPTER);
				handler.setItem(INDEX_TELETEXT_ALL_ITEMS[index + 2]);
				handler.setFields(
						getResources().getString(
								INDEX_CATEGORY_LABEL[index]),
						IndexInfo.INDEXLAST, IndexInfo.INDEXNET, "");
				addToMonitor.setOnClickListener(handler);
				addToMonitor_container.setOnClickListener(handler);
			}

			ImageView imageView = (ImageView) container
					.findViewWithTag(TAG_CHART);
			if (imageView != null)
			{
				imageView.setVisibility(isShouldShowImg(INDEX_TELETEXT_ALL_ITEMS[index + 2]) ? View.VISIBLE
						: View.GONE);
				imageView.setClickable(true);
				imageView.setFocusable(true);
				imageView.setTag(CHART_IMG_TAG_FOR_KEY,
						INDEX_TELETEXT_ALL_ITEMS[index + 2]);

				// --------modified by haibo, 2011-07-28, avoid to click the
				// image to enter chart-----------
				/*
				 * imageView .setOnClickListener(new ForwardToChart(
				 * INDEX_TELETEXT_ALL_ITEMS[index + 2],
				 * getResources().getString( INDEX_CATEGORY_LABEL[index]),
				 * container));
				 */

				imageView.setTag(
						CHART_IMG_TAG_FOR_CLICK,
						new ForwardToChart(
								INDEX_TELETEXT_ALL_ITEMS[index + 2],
								getResources().getString(
										INDEX_CATEGORY_LABEL[index]),
								container));

				// --------modified by haibo, 2011-07-28, avoid to click the
				// image to enter chart-----------

				// add description too see chart
				rotateToseeChart(container);
				// add description too see chart

			}

			for (int item = 0, itemCount = holder.length; item < itemCount; item++)
			{
				// each index has a tag
				holder[item] = (TextView) container
						.findViewWithTag(TAGS[item]);
			}
		}

		for (int index = 0, count = WORLD_INDEX_DELAY_IDS.length; index < count; index++)
		{
			ViewGroup container = (ViewGroup) findViewById(WORLD_INDEX_DELAY_IDS[index]);
			TextView[] holder = _worldIndex_delay[index];
			// ((TextView)container.findViewWithTag(NAME_TAG)).setText(WORLD_INDEX_DELAY_LABEL[index]);
			String nameRes = getResources().getString(
					WORLD_INDEX_DELAY_LABEL[index]);
			((TextView) container.findViewWithTag(NAME_TAG)).setText(Html
					.fromHtml(nameRes));

			changeIndexNameTextForDelayData(container);
			Button addToMonitor = (Button) container
					.findViewWithTag(NAME_ADDTO_MONITOR_TAG);
			ViewGroup addToMonitor_container = (ViewGroup) container
					.findViewWithTag("addto_monitor_tag_container");
			if (addToMonitor != null)
			{
				AddIndexClickHandler handler = new AddIndexClickHandler(
						this);
				handler.setAdapter(WorldIndexDelayInfo.ADAPTER);
				handler.setItem(WORLD_INDEX_DELAY_ITEMS[index]);

				handler.setFields(
						getResources().getString(
								WORLD_INDEX_DELAY_LABEL[index]),
						WorldIndexDelayInfo.LAST,
						WorldIndexDelayInfo.NET,
						WorldIndexDelayInfo.NETPERCENTAGE);
				addToMonitor.setOnClickListener(handler);
				addToMonitor_container.setOnClickListener(handler);
			}

			ImageView imageView = (ImageView) container
					.findViewWithTag(TAG_CHART);
			if (imageView != null)
			{
				imageView.setVisibility(isShouldShowImg(WORLD_INDEX_DELAY_ITEMS[index]) ? View.VISIBLE
						: View.GONE);
				imageView.setClickable(true);
				imageView.setFocusable(true);
				imageView.setTag(CHART_IMG_TAG_FOR_KEY,
						WORLD_INDEX_DELAY_ITEMS[index]);

				// --------modified by haibo, 2011-07-28, avoid to click the
				// image to enter chart-----------
				/*
				 * imageView.setOnClickListener(new ForwardToChart(
				 * WORLD_INDEX_DELAY_ITEMS[index], getResources().getString(
				 * WORLD_INDEX_DELAY_LABEL[index]), container));
				 */

				imageView.setTag(
						CHART_IMG_TAG_FOR_CLICK,
						new ForwardToChart(
								WORLD_INDEX_DELAY_ITEMS[index],
								getResources()
										.getString(
												WORLD_INDEX_DELAY_LABEL[index]),
								container));

				// --------modified by haibo, 2011-07-28, avoid to click the
				// image to enter chart-----------

				// add description too see chart
				rotateToseeChart(container);
				// add description too see chart

			}

			for (int item = 0, itemCount = holder.length; item < itemCount; item++)
			{
				// each index has a tag
				holder[item] = (TextView) container
						.findViewWithTag(TAGS[item]);
			}
		}

	}

	private void rotateToseeChart(ViewGroup container)
	{
		// add description too see chart
		container.setOnFocusChangeListener(new OnFocusChangeListener()
		{

			@Override
			public void onFocusChange(View v, boolean hasFocus)
			{
				TextView rotateToSeeChart = (TextView) (((ViewGroup) v)
						.findViewWithTag("rotate_to_see_chart"));
				ImageView imageView = (ImageView) (((ViewGroup) v)
						.findViewWithTag(TAG_CHART));
				if (rotateToSeeChart != null)
				{
					rotateToSeeChart.setVisibility(hasFocus
							&& (imageView != null)
							&& (imageView.getVisibility() == View.VISIBLE) ? View.VISIBLE
							: View.GONE);
					// modified by haibo, 2011-06-20, no need to do so and it
					// cause the anr. rotateToSeeChart.postInvalidate();
					/*
					 * if((imageView != null) && (imageView.getVisibility() ==
					 * View.VISIBLE)) {
					 */
					_chartImg = imageView; // to allow to enter chart activity
										// any time for adapting to the
										// change on screen changes
					/*
					 * } else { _chartImg = null; }
					 */

				}
			}

		});

		ImageView imageView = (ImageView) (container
				.findViewWithTag(TAG_CHART));
		if ((imageView != null)
				&& (imageView.getVisibility() != View.VISIBLE))
		{
			container.setBackgroundResource(R.drawable.backgound_states_4_no_chart);
		}

		// add description too see chart
	}

	public void onConnectionEstablished()
	{
		// try {
		// Thread.sleep(1000);
		// } catch (InterruptedException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// }
		TDStockLog.d(TAG, "enter ::onConnectionEstablished");
		subscriteIndex();
	}

	// @Override
	// public void onConfigurationChanged(Configuration newConfig)
	// {
	// // TODO Auto-generated method stub
	// /* resetTabBtnWidth();
	// if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
	// if(_chartImg != null) {
	// _chartImg.performClick();
	// }
	//
	// }*/
	//
	// forwardToChartActivity();
	//
	// super.onConfigurationChanged(newConfig);
	// }

	public void resetTabBtnWidth()
	{
		// final ViewGroup tab = (ViewGroup)findViewById(R.id.mock_tab);
		// for(int index = 0, count = tab.getChildCount(); index < count;
		// index++) {
		// final Button btn = (Button)tab.getChildAt(index);
		// btn.setWidth(_display.getWidth() /count);
		// }

		for (int index = 0, count = TAB_BTN_IDS.length; index < count; index++)
		{
			_tabBtns[index] = (Button) findViewById(TAB_BTN_IDS[index]);
			_tabBtns[index].setWidth((_display.getWidth() - count - 1)
					/ count);
		}

	}

	@Override
	protected void onDestroy()
	{
		// TODO Auto-generated method stub
		super.onDestroy();

		/*
		 * if (_streamerTimeoutHandler != null) {
		 * _streamerTimeoutHandler.killCounter(); _streamerTimeoutHandler =
		 * null; }
		 */
	}

	private class AddIndexClickHandler extends DefaultClickHandler
	{
		private String	_item;
		private String	_adapter;
		private String	_fieldName;
		private String	_fieldValue;
		private String	_fieldNet;
		private String	_fieldNetPercentage;
		private String	_iconName;

		public AddIndexClickHandler(Context context)
		{
			super(context);
		}

		public void setItem(String item)
		{
			_item = item;
		}

		public void setIconName(String icnName)
		{
			_iconName = icnName;
		}

		public void setAdapter(String adapter)
		{
			_adapter = adapter;
		}

		public void setFields(String name, String value, String net,
				String netpercentage)
		{
			_fieldName = name;
			_fieldValue = value;
			_fieldNet = net;
			_fieldNetPercentage = netpercentage;
		}

		@Override
		protected void onDefaultAction()
		{

			// 延迟模式
			if (((ITDLApplication) getApplicationContext()).getModeType() == CommonDefn.ModeType.DELARY)
			{
				DBHelper dbHelper = new DBHelper(IndexActivity.this);
				try
				{
					int customerId = ((ITDLApplication) getApplicationContext())
							.getUserId(-1);

					if (dbHelper.isSubscribeItemExist(customerId, _item,
							_adapter))
					{
						new CustomizeDialog(getMyOwnContext(), "",
								getResources().getString(
										R.string.monitor_exist_index))
								.show();
					}
					else if (dbHelper.isFullWithItemInMonitor(customerId))
					{
						new CustomizeDialog(
								getMyOwnContext(),
								"",
								getResources()
										.getString(
												R.string.monitor_is_full_with_items))
								.show();
					}
					else
					{
						long result = dbHelper.insertSubscribeItem(
								customerId, _item, _adapter,
								_fieldName, _fieldValue, _fieldNet,
								_fieldNetPercentage);

						/*
						 * if(result>0) { new
						 * AlertDialog.Builder(IndexActivity.this)
						 * .setTitle(getResources().getString(R.string.info))
						 * .setMessage
						 * (getResources().getString(R.string.monitor_add_to))
						 * .setIcon
						 * (getResources().getDrawable(R.drawable.help_menu_icon
						 * ))
						 * .setPositiveButton(getResources().getString(R.string
						 * .ok), new DialogInterface.OnClickListener(){ public
						 * void onClick(DialogInterface dialoginterface, int i){
						 * 
						 * } }) .show();
						 * 
						 * }
						 */

						if (result > 0)
						{
							// startAnim(genBitMapforAnim(_iconName == null ?
							// _item : _iconName ));
							/* modify by zor(ouyangzhihui) */
							String temp = _iconName == null ? _item
									.substring(0, 2) : _iconName;
							temp = _item.length() >= 2 ? _item
									.substring(0, 2) : _item;
							startAnimat(temp);
						}

						TDStockLog.d(TAG, "insert result:" + result);
					}

				}
				catch (NotFoundException e)
				{
					e.printStackTrace();
					TDStockLog.d(
							TAG,
							"insert result:" + e.getMessage() == null ? "unknown exception!"
									: e.getMessage());
				}
				finally
				{
					dbHelper.cleanup();
				}
			}
			// 非延迟模式
			else
			{
				new SaveBookMarkAsyncTask(_item,
						CommonDefn.BookMarkType.index.getBookMarkType(),
						IndexActivity.this, MonitorUtil.getInstance(),
						_item.length() >= 2 ? _item.substring(0, 2)
								: _item).execute();
			}


		}

	}

	@Override
	protected void onResume()
	{
		super.onResume();

		if (isChangeModeType)
		{
			// "期指Futures"，"上証SSEI" set Adapter
			initFuturesAndSSEIAdapterType();
			initIndexViews();
			isChangeModeType = false;
		}

		resetTitle();

		// TDStockLog.d(TAG, "Size of subscribition OnResume: " +
		// this._subscrRefs.size() );

		{
			final Runnable myUpdateResults = new Runnable()
			{
				public void run()
				{
					scrollToItemView();
				}
			};

			new Thread()
			{
				public void run()
				{
					if (_messageHandler != null)
					{
						_messageHandler.post(myUpdateResults);
					}

				}
			}.start();
		}

		/*
		 * if (!SystemInfo.isNetworkingConnected(this)) { new
		 * CustomizeDialog(getMyOwnContext(), getResources().getString(
		 * R.string.info), getResources().getString(
		 * R.string.networking_disconnect_tips)).show(); return; }
		 */

		/*
		 * if(_isFirstLink || _isExceptionHappend) { final Runnable
		 * myUpdateResults = new Runnable() { public void run() {
		 * connectLightStreamer(); } };
		 * 
		 * new Thread() { public void run() {
		 * _messageHandler.post(myUpdateResults); } }.start(); }
		 */

		/*
		 * if (_streamerTimeoutHandler != null) {
		 * _streamerTimeoutHandler.startCounter(0,0); }
		 */

		/*
		 * if (!((ITDLApplication)
		 * getApplicationContext()).isLightStreamerConnected()) {
		 * 
		 * connectLightStreamerEx(getMyOwnContext()); return; }
		 */

		/*
		 * if (!_isSubscribed) {
		 * 
		 * new SubscriptionTask().execute();
		 * 
		 * }
		 */

		/*
		 * final Runnable myUpdateResults = new Runnable() { public void run() {
		 * if (((ITDLApplication) getApplicationContext())
		 * .isLightStreamerConnected()) { //onConnectionEstablished();
		 * TDStockLog.d(TAG, "ready to subscribe items! "); new
		 * SubscriptionTask().execute(); } else { TDStockLog.d(TAG,
		 * "ready to re-connect the lightstreamer! ");
		 * connectLightStreamerEx(getMyOwnContext()); } } };
		 * 
		 * new Thread() { public void run() { if (_messageHandler != null)
		 * _messageHandler.post(myUpdateResults); } }.start();
		 */
	}

	private void scrollToItemView()
	{
		final String itemCode = ((ITDLApplication) getApplicationContext())
				.getString(CommonDefn.FROM_MONITOR_TO_ACTIVITY_FORWARDING_ITEM);
		final String adapter = ((ITDLApplication) getApplicationContext())
				.getString(CommonDefn.FROM_MONITOR_TO_ACTIVITY_FORWARDING_ADAPTER);
		if (itemCode == null || itemCode.length() < 1 || adapter == null
				|| adapter.length() < 1)
		{
			return;
		}
		((ITDLApplication) getApplicationContext()).putString(
				CommonDefn.FROM_MONITOR_TO_ACTIVITY_FORWARDING_ITEM, null);
		((ITDLApplication) getApplicationContext()).putString(
				CommonDefn.FROM_MONITOR_TO_ACTIVITY_FORWARDING_ADAPTER,
				null);

		if (!ITEM_TO_TABINDEX.containsKey(itemCode + adapter)
				&& !ITEM_TO_TABINDEX.containsKey(itemCode))
		{
			return;
		}

		String key = itemCode + adapter;
		if (ITEM_TO_TABINDEX.containsKey(itemCode))
		{
			key = itemCode;
		}
		final int tabIndex = ITEM_TO_TABINDEX.get(key);
		// final ViewGroup tab = (ViewGroup) findViewById(R.id.mock_tab);
		// final Button tabBtn = (Button) tab.getChildAt(tabIndex);
		final Button tabBtn = _tabBtns[tabIndex];

		if (_messageHandler != null)
			_messageHandler.post(new Runnable()
			{
				public void run()
				{
					tabBtn.performClick();
				}
			});
	}

	private boolean isShouldShowImg(String itemCode)
	{
		boolean result = true;
		/*
		 * final String[] shouldHideItems = { INDEX_TELETEXT_ALL_ITEMS[2],
		 * INDEX_TELETEXT_ALL_ITEMS[3], INDEX_TELETEXT_ALL_ITEMS[4],
		 * INDEX_TELETEXT_ALL_ITEMS[5],
		 * INDEX_TELETEXT_ALL_ITEMS[6],INDEX_TELETEXT_ALL_ITEMS[7],
		 * 
		 * 
		 * WORLD_INDEX_ITEMS[5], WORLD_INDEX_ITEMS[7], WORLD_INDEX_ITEMS[8],
		 * 
		 * WORLD_INDEX_ITEMS[10], WORLD_INDEX_ITEMS[11], WORLD_INDEX_ITEMS[12],
		 * WORLD_INDEX_ITEMS[13], WORLD_INDEX_ITEMS[14], WORLD_INDEX_ITEMS[15],
		 * WORLD_INDEX_ITEMS[16], WORLD_INDEX_ITEMS[17], WORLD_INDEX_ITEMS[18],
		 * WORLD_INDEX_ITEMS[19],
		 * 
		 * WORLD_INDEX_ITEMS[21], WORLD_INDEX_ITEMS[22], WORLD_INDEX_ITEMS[24],
		 * 
		 * WORLD_INDEX_DELAY_ITEMS[0], WORLD_INDEX_DELAY_ITEMS[1],
		 * 
		 * 
		 * };
		 * 
		 * for(String item: shouldHideItems) { if(item.equals(itemCode)) {
		 * result =false; break; }
		 * 
		 * }
		 */

		result = !noChartList.contains(itemCode);

		return result;

	}

	private class ForwardToChart implements OnClickListener
	{
		private String		_itemCode;
		private String		_itemName;
		private ViewGroup	_viewGroup;

		public ForwardToChart(String itemCode, String itemName,
				ViewGroup container)
		{
			_itemCode = itemCode;
			_itemName = itemName;
			_viewGroup = container;
		}

		@Override
		public void onClick(View v)
		{
			if (_itemName == null || _itemName.length() < 1)
			{
				View itemName = _viewGroup.findViewWithTag(NAME_TAG);
				if (itemName != null)
				{
					String strName = ((TextView) itemName).getText()
							.toString();
					TDStockLog.d(TAG, "name=" + strName + "=name");
					if (strName != null && strName.length() >= 1)
					{
						if (strName.contains("月期貨"))
						{
							strName = strName.replace("恆生指數", "恆指")
									.replace("國企指數", "國企")
									.replace("日經指數", "日經")
									.replace("道瓊斯", "道指")
									.replace("期貨", "");
						}
						forwardToNvChart(_itemCode,
								strName.replace("(延遲)", ""));
					}
				}
			}
			else
			{
				_itemName = _itemName.replace("<br>(延遲)", "");
			}
			// currentItemCode = _itemCode;
			forwardToNvChart(_itemCode, _itemName);
		}

	}

	private void forwardToNvChart(final String itemCode, final String itemName)
	{
		/*
		 * if(_display.getWidth() <= _display.getHeight()) { return; }
		 */
		// Intent intent = new Intent(this,NvChart.class);

		if (this.isShouldShowImg(itemCode))
		{

			Intent intent = new Intent(this, IndexChartActivity.class);
			intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
					| Intent.FLAG_ACTIVITY_NO_USER_ACTION);
			if (itemName != null && itemName.length() > 0)
				((ITDLApplication) this.getApplicationContext())
						.setCurrentStockName(itemName); // only get part name on
													// all items
			intent.putExtra(FinalKey.ITEMCODE, itemCode);
			// startActivityForResult(intent, Activity.RESULT_OK);
			// startActivity(intent);
			SwitchActivityFromHost(IndexChartActivity.class, intent);
		}

		// startActivity(intent);
	}

	private void resetTitle()
	{
		if (((ITDLApplication) getApplicationContext()).getDataMode() == CommonDefn.DataMode.Delay)
		{
			_top_bar_title.setText(getResources().getString(R.string.index)
					+ "("
					+ getResources().getString(
							R.string.delay_mode_title_tips) + ")");
		}
		else
		{
			_top_bar_title.setText(getResources().getString(R.string.index));
		}
		// modified by haibo, 2011-06-20, no need to do so and it cause the anr.
		// _top_bar_title.postInvalidate();

	}

	protected Context getMyOwnContext()
	{
		// return _context;
		return getParent();
	}

	private class SubscriptionTask extends AsyncTask<String, Void, Void>
	{

		@Override
		protected Void doInBackground(String... params)
		{
			onConnectionEstablished();
			return null;
		}

		@Override
		protected void onPostExecute(Void result)
		{
			super.onPostExecute(result);
		}

	}

	@Override
	protected void onPause()
	{
		super.onPause();
		TDStockLog.d(TAG, "onPause executed!");
		// unSubscribeItems();
		/*
		 * if (_streamerTimeoutHandler != null) {
		 * _streamerTimeoutHandler.resetCounter(); }
		 */
	}

	@Override
	protected boolean forwardToChartActivity()
	{
		// TODO Auto-generated method stub

		if (_chartImg != null)
		{
			String currentItemCode = _chartImg.getTag(CHART_IMG_TAG_FOR_KEY)
					.toString();

			OnClickListener clicking = (OnClickListener) _chartImg
					.getTag(CHART_IMG_TAG_FOR_CLICK);
			if (currentItemCode == null)
			{

				TDStockLog.d(TAG, "itemCode is null");

				TDStockLog.d(TAG, "not forwardTo chart");

				return false;
			}

			if (this.isShouldShowImg(currentItemCode))
			{
				if (_chartImg != null)
				{

					// --------modified by haibo, 2011-07-28, avoid to click the
					// image to enter chart-----------
					// _chartImg.performClick();
					if (clicking != null)
					{
						clicking.onClick(_chartImg);
					}

					// --------modified by haibo, 2011-07-28, avoid to click the
					// image to enter chart-----------

					TDStockLog.d(TAG, "forwardTo chart");

					TDStockLog.d(TAG, "itemCode:" + currentItemCode);

					return true;

				}
			}

		}

		TDStockLog.d(TAG, "not forwardTo chart");

		TDStockLog.d("Print_Info", "not forwardTo chart");

		return false;
	}

	private void initHasChartList()
	{

		String[] shouldHideItems = { INDEX_TELETEXT_ALL_ITEMS[2],
				INDEX_TELETEXT_ALL_ITEMS[3], INDEX_TELETEXT_ALL_ITEMS[4],
				INDEX_TELETEXT_ALL_ITEMS[5], INDEX_TELETEXT_ALL_ITEMS[6],
				INDEX_TELETEXT_ALL_ITEMS[7],

				WORLD_INDEX_ITEMS_DELAY_AND_REALTIME[1],
				WORLD_INDEX_ITEMS_DELAY_AND_REALTIME[3],
				WORLD_INDEX_ITEMS_DELAY_AND_REALTIME[4],

				WORLD_INDEX_ITEMS[5], WORLD_INDEX_ITEMS[6],
				WORLD_INDEX_ITEMS[7], WORLD_INDEX_ITEMS[8],
				WORLD_INDEX_ITEMS[9], WORLD_INDEX_ITEMS[10],
				WORLD_INDEX_ITEMS[11], WORLD_INDEX_ITEMS[12],
				WORLD_INDEX_ITEMS[13], /* WORLD_INDEX_ITEMS[14], *//*
																	 * 隐藏印度SEN
																	 * index=10
																	 */

				WORLD_INDEX_ITEMS[16 - 1], WORLD_INDEX_ITEMS[17 - 1],
				WORLD_INDEX_ITEMS[19 - 1],

				WORLD_INDEX_DELAY_ITEMS[0], WORLD_INDEX_DELAY_ITEMS[1], };

		for (String temp : shouldHideItems)
		{

			noChartList.add(temp);
		}

		TDStockLog.d(TAG, "by zhengan ====shouldHideItems.size:"
				+ noChartList.size());

	}

	private void reConnectLightstreamerIfDisconnect()
	{
		if (!SystemInfo.isNetworkingConnected(this))
		{
			new CustomizeDialog(getMyOwnContext(), getResources().getString(
					R.string.info), getResources().getString(
					R.string.networking_disconnect_tips)).show();
			return;
		}

		if (!appHost.LSClient_IsConnected())
		{
			connectLightStreamerExt(getMyOwnContext());
		}

	}

	private void changeIndexNameTextForDelayData(ViewGroup container)
	{
		TextView index_name = ((TextView) container.findViewWithTag(NAME_TAG));

		if (TAB4And5Map.containsKey(container.getId()))
		{
			if (((ITDLApplication) getApplicationContext()).getDataMode() == DataMode.Delay)
			{
				if (index_name.getText().toString().indexOf("延遲") != -1)
				{
					String name = index_name.getText().toString();
					index_name.setText(Html.fromHtml(name.substring(0,
							name.length() - "(延遲)".length())));
				}
				index_name.setTextColor(Color.WHITE);
			}
			else
			{
				index_name.setTextColor(Color.YELLOW);
			}
		}
		else if (TAB1And2Map.containsKey(container.getId())) // "期指(Futures)"
		{
			// account login 未購買 "期指(Futures)"
			if ((((ITDLApplication) getApplicationContext()).getModeType() == ModeType.ACCOUNTLOGIN && !((ITDLApplication) getApplicationContext())
					.getIsRealtimeFutures()))
			{
				index_name.setTextColor(Color.YELLOW);
			}
			else
			{
				index_name.setTextColor(Color.WHITE);
			}
		}
		else if (TAB1And3Map.containsKey(container.getId()))// "上証(SSEI)"
		{
			// account login 未購買 "上証(SSEI)"
			if ((((ITDLApplication) getApplicationContext()).getModeType() == ModeType.ACCOUNTLOGIN && !((ITDLApplication) getApplicationContext())
					.getIsRealtimeSSEI()))
			{
				index_name.setTextColor(Color.YELLOW);
			}
			else
			{
				if (index_name.getText().toString().indexOf("延遲") != -1)
				{
					String name = index_name.getText().toString();
					index_name.setText(Html.fromHtml(name.substring(0,
							name.length() - "(延遲)".length())));
				}
				index_name.setTextColor(Color.WHITE);
			}
		}
	}

	@Override
	public ActivityGroupController GetActivityGroupController()
	{
		return IndexGroup.GetActivityGroupHostControl();
	}

	@Override
	public void LS_UserClient_ConnectionReport(final CONNECTION_STATUS iStatus)
	{
		super.LS_UserClient_ConnectionReport(iStatus);
	}

	/*
	 * @Override public void ReporterTicker_Response(int iRemainSecond) {
	 * if(debugMode) TDStockLog.i(GetIdentity(), "RemainSecond = " +
	 * iRemainSecond);
	 * 
	 * if (iRemainSecond == 0) AttachDisconnectMessage();
	 * 
	 * }
	 */

	@Override
	public void onUpdate(String iIdentifier, int iSchemaIndex,
			String iSchemaValue, UpdateInfo iUpdateInfo)
	{

		super.onUpdate(iIdentifier, iSchemaIndex, iSchemaValue, iUpdateInfo);
		if (IDENTIFIER_0.equals(iIdentifier))
		{
			_lightStreamerHandlerOnIndex.onUpdate(iSchemaIndex,
					iSchemaValue, iUpdateInfo);
		}
		else if (IDENTIFIER_1.equals(iIdentifier))
		{
			_lightStreamerHandlerOnWorldIndex.onUpdate(iSchemaIndex,
					iSchemaValue, iUpdateInfo);
		}
		else if (IDENTIFIER_2.equals(iIdentifier))
		{
			_lightStreamerHandlerOnIndexFutures.onUpdate(iSchemaIndex,
					iSchemaValue, iUpdateInfo);
		}
		else if (IDENTIFIER_3.equals(iIdentifier))
		{
			_lightStreamerHandlerOnWorldFutures.onUpdate(iSchemaIndex,
					iSchemaValue, iUpdateInfo);
		}
		else if (IDENTIFIER_4.equals(iIdentifier))
		{
			_lightStreamerHandlerOnWorldIndexDelay.onUpdate(iSchemaIndex,
					iSchemaValue, iUpdateInfo);
		}
		else if (IDENTIFIER_5.equals(iIdentifier))
		{
			_lightStreamerHandlerOnWorldIndexDelayRealtime.onUpdate(
					iSchemaIndex, iSchemaValue, iUpdateInfo);
		}

	}

}
